Import Only Necessary CSV Columns In IDL
Question:
I am struggling to find a function in IDL that will replicate something I have done in Python with Pandas. I am new to IDL and there is next to nothing resource wise that I can find.
In Python, I use the following:
pd.read_csv('<csv filepath>', usecols=[n])
The usecols part will only pull in the columns of a CSV I would like in my data frame. Is there a way to do this in IDL?
I hope this makes sense – my first post here!
Thanks.
Answers:
There is a READ_CSV
routine that can read CSV files, but it does not have a way to pull out specific columns. It will give you a structure with one field for each column of the CSV file — so you could just grab the column you need from the structure and throwing away the rest of the structure. Something like:
csv = read_csv('somefile.csv')
col_n = csv.(n)
I had a similar situation, where I had to read independent columns of a .csv file on idl. Trust me, it was a pain.. But thanks for this wonderful 2 lines of code!
I am struggling to find a function in IDL that will replicate something I have done in Python with Pandas. I am new to IDL and there is next to nothing resource wise that I can find.
In Python, I use the following:
pd.read_csv('<csv filepath>', usecols=[n])
The usecols part will only pull in the columns of a CSV I would like in my data frame. Is there a way to do this in IDL?
I hope this makes sense – my first post here!
Thanks.
There is a READ_CSV
routine that can read CSV files, but it does not have a way to pull out specific columns. It will give you a structure with one field for each column of the CSV file — so you could just grab the column you need from the structure and throwing away the rest of the structure. Something like:
csv = read_csv('somefile.csv')
col_n = csv.(n)
I had a similar situation, where I had to read independent columns of a .csv file on idl. Trust me, it was a pain.. But thanks for this wonderful 2 lines of code!