Modification of a .CSV file

K

kathy.aubin

Hi,

I need to do some changes in a .CSV file.
I have two different changes to make:

1) convert the string 111E+112 (scientific notation) to 00111E110
(string with the zeros at the beginning)

2) convert the number 1234567 to 0001234567 -> I need to keep the
zeros at the beginning

My problem is that, when I do the changes and save the file back
in .CSV format, all the changes are gone, they are not saved. It's
probably because of the format specifics but I really don't know how
to deal with the problem. I need to find a way to save those change in
a .CSV format.

Does somebody know how to bypass this issue?

Thanks much,
 
D

David Biddulph

Are you sure that you've lost the data when you save it as CSV? Have you
looked at the CSV with something like Notepad?

It's likely that you've stored it successfully in the CSV, but that it gets
distorted when you read the CSV back into Excel. If it's OK in the CSV,
copy or rename the CSV as .txt, and then when you read it into Excel you can
specify the relevant columns as text, and thus not get reinterpreted when
you read the data in.
 
K

kathy.aubin

I did what you said and it is not saving the change. When I save
into .CSV format, I get a message telling me that I might lose
informations if I save it that format instead of .xls format.
Thanks for your help
 
D

David Biddulph

What does the data look like in the Excel document from which you are
saving?
What are the cell contents, and what does the cell format say?
What does it then look like in the CSV?
 
D

Dave Peterson

It sounds like you may have taken that warning about losing format too
seriously.

If you're worried, save a copy as a normal workbook. Then save it as a .CSV
file.

Then close excel and open that .CSV file in Notepad to verify that it worked.

I'm betting that the second, er, next time you do this, it'll work fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top