0
$\begingroup$

How to ensure the numbers in CSV are 1 and not 1.

Data is imported from an excel, wherein they are detected as numbers and imported as 1., 2. etc. This poses a problem while exporting the again as csv

For example:

ExportString[
ImportString["a,b,c\n1.,NULL,d", "CSV"] (* emulating a import from excel 
*), 
"CSV"]

Gives the output as (which is written to the CSV file using Export["file.csv",Import["file.xls"]]):

"a","b","c"
1.,"NULL","d"

whereas the expected output is:

"a","b","c"
1,NULL,"d"

Is there a way to elegantly control such outputs/ behaviour of the CSV writer?

$\endgroup$
  • $\begingroup$ ExportString[ ImportString[ StringReplace["a,b,c\n1.,NULL,d", ".," -> ","], "CSV"], "CSV"] $\endgroup$ – Bob Hanlon Feb 8 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.