Tag Info

New answers tagged

2

I would read the csv file as a stream. It's very quick. First, I use the following function to look for specific lines. ClearAll[readLine]; readLines[stream_, search_?StringQ] := With[{stro = FindList[stream, search]}, ImportString[StringJoin[Riffle[stro, "\n"]], "Table"] /; stro =!= {}] Then I open a stream: file = "data.csv"; str = ...


1

Leonid provided the following demo in chat: the basic idea is to use R's read.table header management before coming back to Mathematica. file = URLSave["http://samplecsvs.s3.amazonaws.com/TechCrunchcontinentalUSA.csv"]; Needs["RLink`"] InstallR[]; RSet["testfile", file]; REvaluate["testdata <- read.table(testfile, header=TRUE)"]


1

This method will work with the ragged data array provided. Example 1 data = Import["henris_data_s3.csv"]; vnames = Transpose[data[[{1, 2}]]]; vnames[[99]] {"L1_INJ", "GWIR"} Above is the 'name' of the 99th record. Table[vdata[vnames[[i]]] = DeleteCases[Drop[Map[ Quiet[Check[Part[#, i], Null]] &, data], 4], Null], {i, Length[vnames]}]; ...


0

I don't know the answer to this question with a header of many lines and unique identifier specified by many lines. I am trying to create discussion about this in chat. Alternative solution with *ix tools Edit the original file to simpler form with instructions here so simplified datadump here and now read the simplified CSV into Mathematica where ...



Top 50 recent answers are included