comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to read a csv file?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
How to read a csv file? [message #86174] Wed, 16 October 2013 07:46 Go to next message
galaxytraveler42 is currently offline  galaxytraveler42
Messages: 5
Registered: October 2013
Junior Member
I have tried using the read_csv command:

data = read_csv(path+'filename.csv',HEADER=SedHeader)

and it it seems to work:
Help, data:
** Structure <2161e08>, 28 tags, length=5600, data length=5600, refs=1:
FIELD01 STRING Array[20]
FIELD02 STRING Array[20]
FIELD03 DOUBLE Array[20]
FIELD04 DOUBLE Array[20]
FIELD05 DOUBLE Array[20]
.... (I have shortend it here)

print, SedHeader
id full_name diameter H extent ...

Now I would like to have the different columns in the csv out in individuel arrays. But here is my problem, what is the command?

I have tried without luck:
print, diameter
>%PRINT: Variable is undefined: DIAMETER.
print, field03
>% PRINT: Variable is undefined: FIELD03.
col3=data(3, *)
print, col3
>% Attempt to subscript DATA with <INT ( 3)> is out of range.

What is the magic word?


PS: I am using a Mac computer
Re: How to read a csv file? [message #86175 is a reply to message #86174] Wed, 16 October 2013 07:52 Go to previous messageGo to next message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den onsdagen den 16:e oktober 2013 kl. 16:46:44 UTC+2 skrev galaxytr...@gmail.com:
> I have tried using the read_csv command:
>
> data = read_csv(path+'filename.csv',HEADER=SedHeader)
>
> and it it seems to work:
> Help, data:
> ** Structure <2161e08>, 28 tags, length=5600, data length=5600, refs=1:
> FIELD01 STRING Array[20]
> FIELD02 STRING Array[20]
> FIELD03 DOUBLE Array[20]
> FIELD04 DOUBLE Array[20]
> FIELD05 DOUBLE Array[20]
> .... (I have shortend it here)
>
> print, SedHeader
> id full_name diameter H extent ...
>
> Now I would like to have the different columns in the csv out in individuel arrays. But here is my problem, what is the command?
>
> I have tried without luck:
> print, diameter
>> %PRINT: Variable is undefined: DIAMETER.
> print, field03
>> % PRINT: Variable is undefined: FIELD03.
> col3=data(3, *)
> print, col3
>
>> % Attempt to subscript DATA with <INT ( 3)> is out of range.
>
> What is the magic word?

I have never used read_csv but the fact that the data is a structure suggests that this should do it:

print,data.field03
Re: How to read a csv file? [message #86194 is a reply to message #86175] Thu, 17 October 2013 05:44 Go to previous message
galaxytraveler42 is currently offline  galaxytraveler42
Messages: 5
Registered: October 2013
Junior Member
Thank you! Those where the magic words that unlocked my data.



On Wednesday, October 16, 2013 4:52:43 PM UTC+2, Mats Löfdahl wrote:
> Den onsdagen den 16:e oktober 2013 kl. 16:46:44 UTC+2 skrev galaxytr...@gmail.com:
>
>> I have tried using the read_csv command:
>
>>
>
>> data = read_csv(path+'filename.csv',HEADER=SedHeader)
>
>>
>
>> and it it seems to work:
>
>> Help, data:
>
>> ** Structure <2161e08>, 28 tags, length=5600, data length=5600, refs=1:
>
>> FIELD01 STRING Array[20]
>
>> FIELD02 STRING Array[20]
>
>> FIELD03 DOUBLE Array[20]
>
>> FIELD04 DOUBLE Array[20]
>
>> FIELD05 DOUBLE Array[20]
>
>> .... (I have shortend it here)
>
>>
>
>> print, SedHeader
>
>> id full_name diameter H extent ...
>
>>
>
>> Now I would like to have the different columns in the csv out in individuel arrays. But here is my problem, what is the command?
>
>>
>
>> I have tried without luck:
>
>> print, diameter
>
>>> %PRINT: Variable is undefined: DIAMETER.
>
>> print, field03
>
>>> % PRINT: Variable is undefined: FIELD03.
>
>> col3=data(3, *)
>
>> print, col3
>
>>
>
>>> % Attempt to subscript DATA with <INT ( 3)> is out of range.
>
>>
>
>> What is the magic word?
>
>
>
> I have never used read_csv but the fact that the data is a structure suggests that this should do it:
>
>
>
> print,data.field03
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Store differents size of .fits into one single array
Next Topic: More Kriging Problems

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:13:05 PDT 2025

Total time taken to generate the page: 0.00619 seconds