I want to run an LTSpice simulation with data acquired from an actual, real circuit. I have multiple files containing data from different scenarios and I need to consider them all. Is there a way to run the simulation multiple times, using data from a different file each time?

Here's a simplified schematic to illustrate what I've tried - it doesn't work (I get an error: Could not open file "c:\data" in PWL):

Schematic for illustration

The folder C:\Data\ contains ten files, named 10.txt, 20.txt, ..., 100.txt. The sim works fine if I specify an actual file name in PWL file.

Any suggestions how I can make this work? It would really help my task to see the data from the various scenarious (different motor speeds) in one diagram.

Thanks a lot!



1 Answer 1


You can do it, but you have to adapt a bit. First, make sure that your filenames are strictly numeric and have no extensions. Windows, in particular, tends to hinde, by default, the extensions, and the filenames appear to have none, but they do.

With these in mind, suppose you have two files that you need to .step. Then rename the first 1, and the second 2. Or 314 and 666, it doesn't matter as long as they are numbers. This is needed because .step cannot perform evaluation, only substitution:

.step param x {a} {b}   ; does not work, needs numeric literals

Then you have to move them in the same folder as the schematic. If the schematic is test.asc, then a listing will show:


This is also important, since now the source loading the files needs to be like this:

PWL file={x}
.step param x list 1 2   ; or 314 666, or ...

If there is a path before {x}, it will not work:

PWL file=/path/to/{x}   ; error: "Cannot open ''/path/to'' in PWL"
PWL file={/path/to/x}   ; also error

Now it will work:


  • 1
    \$\begingroup\$ Excellent. This is exactly what I was looking for. It works fine, thanks you for your help! \$\endgroup\$
    – merendo07
    May 3, 2021 at 11:04

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.