Generating SDDS files with PERL

Moderators: cyao, michael_borland

Post Reply
tennant
Posts: 85
Joined: 31 Jul 2008, 07:19
Location: Jefferson Laboratory

Generating SDDS files with PERL

Post by tennant » 06 Aug 2008, 08:38

Hi,

I am writing a simple script in PERL that takes the output of another program and adds the appropriate SDDS header so I can use all the functionality of the SDDS Toolkit. At first the script seems to be working. An output file is created which Windows recognizes as having an .sdds extension and a quick "sddscheck" turns out ok. However, when I try to use sddsplot (for example) I see no data. I can solve the problem by opening the file with a text editor and saving as an .sdds file. (I am asked if I want to overwrite the previous file which I do). By doing this, I can use sddsplot. While this is a fairly straightforward fix, the point of the script is to make this conversion on many files and I'd rather not have to open each file and "save as".

Any help would be greatly appreciated!

--chris

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Generating SDDS files with PERL

Post by michael_borland » 06 Aug 2008, 08:45

Chris,

Can you post one of the files that gives the problem? I suspect a problem with end-of-line characters.

--Michael

tennant
Posts: 85
Joined: 31 Jul 2008, 07:19
Location: Jefferson Laboratory

Re: Generating SDDS files with PERL

Post by tennant » 06 Aug 2008, 09:02

Hi Michael,

I've attached a file.

--chris
Attachments
tmp.sdds
(11.52 KiB) Downloaded 167 times

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Generating SDDS files with PERL

Post by michael_borland » 06 Aug 2008, 09:14

Chris,

The problem seems related to lack of new-line characters in the body of the file. For example, if I run "sdds2stream tmp.sdds -rows", it says "1 row". Also, "wc tmp.sdds" returns 22 as the number of lines---that's the header plus 1 line.

When I examine the file with "od -ba tmp.sdds", it shows that in the header you have carriage-return/line-feed at the end of each line, while in the body you have carriage-return only. So perhaps some modification of the perl code to write the body of the file the same way as the header will resolve the problem.

--Michael

tennant
Posts: 85
Joined: 31 Jul 2008, 07:19
Location: Jefferson Laboratory

Re: Generating SDDS files with PERL

Post by tennant » 06 Aug 2008, 09:23

Hi Michael,

Thanks for the suggestion. It appears that if each line in the body ends with a line-feed, then things are resolved.

--chris

Post Reply