Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am reading in some data from a CSV file that has a line which gives titles to each "column".

Here is an example:

Entry No,Val1,Val2,Val3,Val4
0,1.01,1.345,5.234,345.45
1,2.456,1.256,250.56,45.027

In reality this file has 20 or so values on each line, and therefore 20 column titles on the first line. I want to display this data in a table, so I first import the file and then display it like so:

dataSet1 = Take[Import["data_set_1.csv","CSV","HeaderLines"->1]] 
TableForm[dataSet1]

I want to be able to manipulate and plot my data later so I am pretty sure I have to remove the line containing the labels using the "Headerlines->1" option.

I would like the table to display the column titles that were on he first line of the CSV file. I know that I could specify them manually, but I think there should be someway to do this because I deleted them the set using "HeaderLines"

share|improve this question

1 Answer 1

up vote 3 down vote accepted
data= Import["http://pastebin.com/raw.php?i=7jJ4e2jW"];
titles = First@data; data = Rest@data;
TableForm[data, TableHeadings -> {None, titles}]
(*Displays the Table *)
(*Do Something with Data*)
ArrayPlot[data] 

enter image description here

share|improve this answer
    
thank you for your answer. I was actually asking about putting the titles on the table not on a plot. Also I tried to use your method of first and rest but It gave me errors. –  Ajay Jul 25 at 19:29
    
@Ajay This answer works perfectly with me. It also produces a table with the desired headings. –  eldo Jul 25 at 20:50
    
@eldo The answer has been edited since I tried to get that to run I for got that I needed to put None as the row labels in the table. –  Ajay Jul 25 at 21:05
    
Thank you @patoCriollo this is great –  Ajay Jul 25 at 21:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.