2

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"

Ajay
  • 227
  • 2
  • 9

1 Answers1

3
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

Zviovich
  • 9,308
  • 1
  • 30
  • 52
  • 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 '14 at 19:29
  • @Ajay This answer works perfectly with me. It also produces a table with the desired headings. – eldo Jul 25 '14 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 '14 at 21:05