0
$\begingroup$
Ydata = Import[
     FPath <> "TEK" <> IntegerString[4, 10, 4] <> ".CSV", {"Data", #, 
      5}] & /@ Range[2500];
Xdata = Import[
     FPath <> "TEK" <> IntegerString[4, 10, 4] <> ".CSV", {"Data", #, 
      4}] & /@ Range[2500];

Importing CSV files takes around 8-10 minutes per file, which is ridiculously slow, for a 74KB file, with 2500 rows of data and 2 column data. Is there anyway to speed it up? CSV is a file which can be opened by excel.

What my code does is importing TEK file with 1004 header number with csv format

A screenshot of the file is taken for clarification.enter image description here

$\endgroup$
5
$\begingroup$

Your code opens and closes the file 2500 times for each variable. That will create some overhead. You may use the "Data" import specification for "CSV" with All and Transpose.

{xData, yData} = 
 Transpose@
  Import[FPath <> "TEK" <> IntegerString[4, 10, 4] <> ".CSV", 
     {"Data", All, {4, 5}}]

Also, do not begin your symbol names with a capital letter as you can bump into issues with built-in symbols

Hope this helps.

$\endgroup$
  • $\begingroup$ i spent some time using python instead, python imports take only 1second and your answer helps me to use mathematica again! Mathematica is still superior over python in fitting... I took hours (with not much experience) to fit in python, but seconds in mathematica.. $\endgroup$ – el psy Congroo Apr 9 '17 at 20:56
  • 1
    $\begingroup$ This import also only takes a second in Mathematica when it is written the Wolfram Language way. $\endgroup$ – Edmund Apr 9 '17 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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