X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 25 Nov 2011 05:19 AM by  anon
read_csv column names to a structure?
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
25 Nov 2011 05:19 AM
    Hello, I am trying to use the read_csv function where the first line in the csv has the column names. I tried using the # in front of the names but i get the result of FIELD1, FIELD2, etc. I tried looking in the help but didnt see any usage on the # mark, I found that tip here http://web.astroconst.org...doc/io/read_csv.html my code datstruc = read_csv(datfile.csv,header) datfile.csv file (just the first 5 rows) NAME,aPH,aSM,bPH,bSM 398.6,1,10,100,1000 439.2,2,20,200,2000 458.3,3,30,300,3000 479.8,4,40,400,4000 output FIELD1 DOUBLE Array[15] FIELD2 LONG Array[15] FIELD3 LONG Array[15] FIELD4 LONG Array[15] FIELD5 LONG Array[15] I dont want to write code just to rename the fields of the structure if i dont have to. Any suggestions?

    Deleted User



    New Member


    Posts:
    New Member


    --
    05 Dec 2011 01:59 PM
    Perhaps you could create a template for the file using the ASCII_TEMPLATE routine. This will allow you to name the different fields in the file. Then, you can read the file using the READ_ASCII function with the TEMPLATE keyword.

    Deleted User



    New Member


    Posts:
    New Member


    --
    06 Dec 2011 07:35 AM
    I will give that a try and post back. thanx.
    You are not authorized to post a reply.