New answers tagged

0

ReadList with Word It seems to me that the best you can do with ReadList in this case is to parse each line of the file and get the field values back as strings. For the monetary comma value, you get a list with two string values and this is the major obstacle to tackle. Note that this ReadList use has already been added to my question above, but nobody ...


3

Here are some approaches with slightly modified versions of your input CSV file. If you are looking for an efficient way to read the data, the input data should be as friendly as possible to MMA. However in the last example, I will give one possible way to process your original data. 1. ReadList with formats With this approach, the most problematic in ...


2

As long as you are using ReadList to read in the entire file, and then acting on each line, you may as well just feed the result of ReadLine into ImportString. test = ImportString[ StringJoin[ Riffle[ReadList["shoes_revenue.csv", String], "\n"] ], "CSV"]; // AbsoluteTiming (*{2.7918, Null}*) which is marginally faster than this answer ...


1

I am not sure what exactly you are looking for, but you could apply ToExpression to those columns that should be Integers instead of Strings: Head@ToExpression["1234"] (* Integer *) Similarly, you can combine the last two columns, drop the Dollar symbol and convert to integer: ToExpression@StringDrop["$2" <> "843", 1] (*2843 *)



Top 50 recent answers are included