Ask Your Question
0

how to get pure data without titles in .txt out files

asked 2021-05-25 08:19:05 -0500

breeze2021 gravatar image

updated 2021-05-25 10:04:05 -0500

jconto gravatar image

Hi, everyone!

I used the following code to output the results of dynamic simulations:

output_obj = dyntools.CHNF('D:\python_test.out')
output_obj.txtout(channels=1)

But the output txt file looks like this:

D:\IEEE 9\python_test_1.out
IEEE 9 BUS CASE - 3G - 3L
                     1       
        Time(s) FREQ 1 [BUS1 1
                        6.500]
     -0.0166667              0
    -0.00833333    2.70645E-11
              0    1.99895E-11
              0    1.99895E-11
     0.00833333    2.41407E-11
      0.0166667   -0.000255582

I have to delete the title manually and then deal with the data. I wondered if there is a method which can output pure data without title. So I can deal with the data directly in python. Any other better methods to output the results of dynamic simulation would be great as well.

I would really appreciate your help!

Thanks a lot!

edit retag flag offensive close merge delete

Comments

Why not just skip those lines when reading the file?

perolofl gravatar imageperolofl ( 2021-05-25 10:26:07 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2021-06-02 09:33:44 -0500

boat14 gravatar image

updated 2021-06-02 09:34:49 -0500

I have a brute force python script that:

  1. Scans the current working directory for all .out files. Or you can specify the file names.
  2. Makes a .csv for each .out file.
  3. Dumps all output channels in plaintext to the .csv file.

Keep in mind, this was for PSS/e 33 and Python 2.7. You can use this as a guide for adapting it to your needs or even specifying specific channel #'s/names:

# out2csv.py
# ---- Start of imports -------------------------------------------------------

import sys
import glob

sys.path.append("C:\Program Files (x86)\dev\psse33r12\PSSBIN")
sys.path.append("C:\Program Files (x86)\dev\psse33r12\PSSPY27")  # dyntools.pyc location

import dyntools

# ---- End of   imports -------------------------------------------------------


# ---- Start of main() --------------------------------------------------------
if __name__ == "__main__":

    # Process filename arguments (if supplied)
    if(len(sys.argv) >= 2):
        out_files = sys.argv[1:]
    else:
        out_files = glob.glob("*.out")


    for ctr, out_file in enumerate(out_files):
        obj = dyntools.CHNF(out_file,
                            outvrsn = 0)

        obj.csvout(outfile = out_file)

        # Progress display
        pc = (ctr + 1.0) / len(out_files) * 100.0
        print'\r[%i %%] |%-20s|' % (pc, '-' * int(pc * 20.0 / 100.0)),
# ---- End of   main() --------------------------------------------------------
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

2 followers

Stats

Asked: 2021-05-25 08:19:05 -0500

Seen: 238 times

Last updated: Jun 02 '21