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


1 Answer 1


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} = 
  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.

  • $\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$ Apr 9, 2017 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, 2017 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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