views:

34

answers:

2

Hello Everyone, How do you get around the exponential conversion that takes place when inserting a value into a csv file. I have a process that creates a csv file and then starts entering rows into it. One of those fields inside a row inserts a value similar to this:

123,45,45,466,6656,23423,2455,234,2454

These are just a string of id's i need to preserve on the csv file in order to import them into another program that expects a comma separated number of values in this field.

Of course when i open excel and look at this csv it gives me something like this: 123,45,45,466,6656,000,000,000,000

so those last few values mean nothing to the import process and it fails.

My question is how do i write to a csv file and get around my values being converted to exponential numbers as well as preserving the comma separated number values like above?

Thanks in advance Billy

+1  A: 

Put quotes around them

"123","45","45","466","6656","23423","2455","234","2454"

Dick Kusleika
Thanks for your response and this would work should i not have to import the data with a format like above: 123,45,45,466,6656,23423,2455,234,2454I tried importing with "" around all values and the third party import process choked. I am going to call them(Volusion.com) about this issue as i know other customers would have to run into the same problem as mine.
Billy Logan
I think I misunderstood the question. How are you writing the CSV file? Are you saving an excel file as CSV or using VBA to write it? If you use VBA, you should be able to avoid the problem.
Dick Kusleika
I am creating the csv file through c# and the streamwriter object. However, i have found a solution. see below. Thank you for your time.
Billy Logan
A: 

In order to get around this issue i used the following steps in MS Excel 2007:

  1. Open a Blank Workbook in Excel.
  2. Choose Data, Get External Data, Import Data. (Excel 2007 is Data, Get External Data, Data from Text)
  3. Browse to your .csv file and Select "Import".
  4. Import Wizard should appear.
  5. Page 1 Select "Delimited"
  6. Select the row which you want to start the import.
  7. click "Next"
  8. In the Delimiters, select "comma" and/or other delimiters you are using. Note: The bottom half of the window will preview the way the data is to be imported.
  9. click "Next"
  10. highlight each column of your data in the window below. For each column you can specify "General", "Text", "Data", or "do not import column" using the radio buttons in the top left of the Wizard box. I used the "Text" option. This is an optional step.
  11. Click Finish.
Billy Logan