Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Import CSV can not understand string correctly
Replies: 5   Last Post: Sep 25, 2013 2:26 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Dr.J

Posts: 22
Registered: 5/30/12
Re: Import CSV can not understand string correctly
Posted: Sep 23, 2013 10:20 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


Thanks for your answer. I have just tested it. It works in the sense of
3D22 can be stored in string.

However, there are three main problems:

1- The whole line(recored) in the .csv file is stored in a single string in
Mathematica. All the fields separated by comma in .csv file are merged into one
string in Mathematica.

2- the comma are written together with two double quote sign in the string
in Mathematica, which is "\",\"". So, the double quote is a real string and not
a symbol.

3- numbers in the .csv file are transformed into strings and belong to part
of the line strings in Mathematica.

These together make the data very difficult to process. Then there is no
difference for me to use ReadList rather then Import to read the file and
then add many StringReplace or ReplacePart or ReplaceAll and so on to
do complicated text processing.

Since Import["filename", CSV] works fine for everything except the
misunderstanding of specific string format. Is there any way to still use
it and just disable transform 3D22 like string to number?


On Sat, Sep 21, 2013 at 4:32 PM, Bob Hanlon <hanlonr357@gmail.com> wrote:

> This works for me:
>
> data = Import["filepathname", "Table"]
>
>
>
> Bob Hanlon
>
>
>
>
> On Sat, Sep 21, 2013 at 4:36 AM, Joug Raw <jougraw@gmail.com> wrote:
>

>>
>> In my CSV file, I have string fields like 3D22 or so.
>> While I imported the CSV file in mathemtaica, the 3D22 string was
>> converted
>> to number 3x10^22.
>>
>> How dose this happened??? How can I avoid this kind of transformation and
>> keep my original string when Import a CSV file?
>>
>>
>>

>





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.