LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-04-2013, 07:30 AM   #1
Berntt
LQ Newbie
 
Registered: Jun 2013
Posts: 3

Rep: Reputation: 0
gnuplot data file requirements?


Hi!

I am using a shell script to modify a data file with awk and redirecting the standart output to a new data file.
Now, when I am trying to plot the new data file with gnuplot, it won't do so.
However, when I open the new data file with gedit and save it WITHOUT ANY CHANGES, it will work correctly.

This is very annoying and no practical solution.

Can anyone tell me the reason?
 
Old 06-04-2013, 07:54 AM   #2
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Difficult to make a suggestion without more detail.
An initial thought is that your original data file may be using the DOS style CR/LF line endings which are being automatically changed to *nix style LF line endings after saving with gedit.
Do you see a change in file size before and after saving with gedit?
Does 'cmp -l <original file> <final file>' give any clues?
 
1 members found this post helpful.
Old 06-04-2013, 08:48 AM   #3
Berntt
LQ Newbie
 
Registered: Jun 2013
Posts: 3

Original Poster
Rep: Reputation: 0
Looks like you are on to something.

file sizes do not differ.
cmp output is
Code:
differ: byte 56, line 2
in gedit, the file looks like this (exerpt):
-46.95 10.8 5.7 7.270 952.7
-46.7833 10.7 5.6 0.001 952.8
-46.6167 10.7 5.5 0.005 952.8
-46.45 10.6 5.8 0.006 952.8
-46.2833 10.5 5.4 0.008 952.9
-46.1167 10.5 6.0 0.011 952.9

Code:
cat -A file_not_saved_by_gedit
results in this:
-46.95^I10.8^I5.7^I7.270^I952.7^M-46.7833^I10.7^I5.6^I0.001^I952.8^M-46.6167^I10.7^I5.5^I0.005^I952.8^M-46.45^I10.6^I5.8^I0.006^I952.8^M-46.2833^I10.5^I5.4^I0.008^I952.9^M-46.1167^I10.5^I6.0^I0.011^I952.9^M-45.95^I10.5^I5.4^I0.013^I953.0^M-45.7833^I10.4^I6.0^I0.017^I953.1^M-45.6167^I10.4^I5.2^I0.025^I953.1^M-45.45^I10.3^I6.2^I0.033^I953.1^M-45.2833^I10.3^I5.3^I0.046^I953.1^M-45.1167^I10.3^I5.6^I0.067^I953.1^M-44.95^I10.3^I4.9^I0.095^I953.1^M-44.7833^I10.2^I5.0^I0.107^I953.2^M-44.6167^I10.2^I3.9^I0.113^I953.2^M-44.45^I10.2^I5.2^I0.127^I953.2^M-44.2833^I10.1^I5.7^I0.187^I953.2^M-44.1167^I10.0^I4.8^I0.576^I953.3^M-43.95^I10.0^I5.1^I1.026^I953.3^M-43.7833^I10.0^I3.9^I1.405^I953.3^M-43.6167^I9.9^I5

and so on
while


Code:
cat -A file_saved_by_gedit
outputs:
-46.95^I10.8^I5.7^I7.270^I952.7$
-46.7833^I10.7^I5.6^I0.001^I952.8$
-46.6167^I10.7^I5.5^I0.005^I952.8$
-46.45^I10.6^I5.8^I0.006^I952.8$
-46.2833^I10.5^I5.4^I0.008^I952.9$
-46.1167^I10.5^I6.0^I0.011^I952.9$
-45.95^I10.5^I5.4^I0.013^I953.0$

I have already tried the dos2unix command without success.
Would sed help with this?
 
Old 06-04-2013, 09:31 AM   #4
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Quote:
-46.95^I10.8^I5.7^I7.270^I952.7^M
The ^I is the TAB character, so your original file is TAB delimited.
The ^M is the CR (carriage return) character, so your original file is using CR without LF to end a line, as the file sizes do not differ. gedit seems to be automatically changing the CR line ending to the LF line ending.

I suggest using tr rather than sed.
Code:
cat <original file> | tr '\r' '\n' > <final file>
 
1 members found this post helpful.
Old 06-04-2013, 11:39 AM   #5
Berntt
LQ Newbie
 
Registered: Jun 2013
Posts: 3

Original Poster
Rep: Reputation: 0
solved

great, this works perfectly.
that was really driving me nuts.
thanks a lot!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Plotting realtime data with GNUPLOT john_erlandsson Linux - Software 3 11-04-2011 04:42 PM
Trouble with Gnuplot and time data javawench Linux - Software 1 01-15-2009 07:07 PM
gnuplot - do multiple plots from data file with built-in commands Meson Linux - Software 2 07-30-2008 03:52 PM
gnuplot, pull X data from file, specify Y data at cmd line? hedpe Programming 5 03-15-2007 11:32 PM
gnuplot: how to label x-axis with strings from data file? hedpe Linux - Software 2 07-11-2006 10:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration