function socialcalc_parse_csv in Sheetnode 7.2
Same name and namespace in other branches
- 6 socialcalc.inc \socialcalc_parse_csv()
- 7 socialcalc.inc \socialcalc_parse_csv()
File
- ./
socialcalc.inc, line 535 - SocialCalc manipulation functions.
Code
function socialcalc_parse_csv($file) {
$sc = array(
'sheet' => array(),
'edit' => socialcalc_default_edit(),
'audit' => socialcalc_default_audit(),
);
if ($handle = fopen($file, 'r')) {
$r = 1;
while ($row = fgetcsv($handle)) {
$c = 1;
foreach ($row as $value) {
$cell = array(
'pos' => array(
$c,
$r,
),
'datatype' => is_numeric($value) ? 'v' : 't',
// TODO: Can do better at inferring valuetypes.
'valuetype' => is_numeric($value) ? 'n' : 't',
'datavalue' => $value,
);
$sc['sheet']['cells'][] = $cell;
$c++;
}
$r++;
}
fclose($handle);
}
return $sc;
}