Author Topic: LTSpice export data as txt, reducing number of points  (Read 6007 times)

0 Members and 1 Guest are viewing this topic.

Offline CloudTopic starter

  • Regular Contributor
  • *
  • Posts: 194
  • Country: si
LTSpice export data as txt, reducing number of points
« on: January 18, 2022, 07:33:28 pm »
So for dissertation I need a few plots from different programs which I hate so I have created python script to create plots from csv files. Now the problem is with LTSpice file which is 1.8GB. Is there a way that I can export every 10th or 100th point?
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 4195
  • Country: us
Re: LTSpice export data as txt, reducing number of points
« Reply #1 on: January 18, 2022, 08:29:01 pm »
After exporting the plot data as a txt file you can use a variety of text processing tools to extract every n-th line.

Using Unix utilities (which are available under Windows with WSL):

https://unix.stackexchange.com/questions/369181/printing-every-nth-line-out-of-a-large-file-into-a-new-file

and here is a streaming solution with Python:

https://stackoverflow.com/a/51744520/866915
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17806
  • Country: fr
Re: LTSpice export data as txt, reducing number of points
« Reply #2 on: January 18, 2022, 08:41:53 pm »
I suppose the OP would like to find a way for LTSpice to generate smaller files, to avoid having to store, and handle large text files to begin with. The rest, they can probably do it?

LTSpice can export plots to "text" files - those are actually CSV, with the separator being a TAB character.
Unfortunately, I don't think there is any setting for this. Even the format itself (including the separator) is not modifiable.

An alternative would be to read the RAW files directly, instead of exporting plots to text as an intermediate. I believe there are libraries for reading those RAW files.
Take a look at this: https://www.nunobrum.com/pyspicer.html
 

Offline CloudTopic starter

  • Regular Contributor
  • *
  • Posts: 194
  • Country: si
Re: LTSpice export data as txt, reducing number of points
« Reply #3 on: January 23, 2022, 07:34:05 pm »
I have found out that files are not the same size for different C size in simulation. So I am thinking one option would be to separate txt file into separate runs (or just run fixed simulations instead of step) and than create a python script to reduce number of lines in each txt file so all files will have same number of lines
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 4195
  • Country: us
Re: LTSpice export data as txt, reducing number of points
« Reply #4 on: January 23, 2022, 07:57:00 pm »
Note that it's possible that the time coordinates in the files won't be the same between simulations:

https://groups.io/g/LTspice/topic/50218484

so I imagine you'll want the python scripts to do some interpolating so all of the data has a uniform time base.



 

Offline CloudTopic starter

  • Regular Contributor
  • *
  • Posts: 194
  • Country: si
Re: LTSpice export data as txt, reducing number of points
« Reply #5 on: January 30, 2022, 08:22:18 pm »
Probably I will just run single simulation for every value C and then plot every run separately into same plot. That way I believe everything will be correctly aligned.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->