Import exponetial fixed width format data into Excel
Posted
by Tom Daniel
on Super User
See other posts from Super User
or by Tom Daniel
Published on 2010-01-26T07:59:57Z
Indexed on
2010/03/15
19:10 UTC
Read the original article
Hit count: 452
I've received a bunch of text data files consiting of Lots of records (>30K/file) of 3 fields each of 5-place numbers in exponential format: s0.nnnnnEsee (where s is +/-, n is a digit and ee is the exponent (always 2 digit). When I open the file in Notepad, the format is perfectly uniform throughout each file, but when I import it to Excel using Data|Import|Fixed Width, many of the data values get messed up, no matter what format (text, exponential, various custom tries) I assign to the cells.
Looking at the Notepad version, it appears that leading + signs were replaced with a space in the data file, but the sign of the exponential is always there. This means that some fields begin with a space, and this appears to confuse the Excel import routine. I get the same result in Excel 2003 and 2007.
I'm sure there's a straightforward solution (hopefully without a messy VBA routine), but I can't figure out what to try next. :-)
To clarify (hopefully), here are some input records and the corresponding text input to Excel:
Notepad Excel
-0.11311E+01 0.10431E-04 0.27018E-03 -0.11311E 1.0431E-05 2.7018E-04 0.19608E+00-0.81414E-02-0.89553E-02 0.19608E -8.1414E-03 8.9553E-03 etc.
Whoopee! Solved my own problem - in the spirit of Jeopardy, now that I've begun the question, here's the answer - Use a different "File Origin" - several other than the default "Unicode UTF..." work fine! What a pain. Hope this helps somebody else avoid a few unpleasant hours!
Aloha from Kona, Tom
© Super User or respective owner