LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   plot using .dat file (https://www.linuxquestions.org/questions/linux-newbie-8/plot-using-dat-file-4175590279/)

usamaAkhtar 09-27-2016 05:36 PM

plot using .dat file
 
1 Attachment(s)
hi!

i need help to plot certain values which i have saved in a .dat file.
here is the screenshot of .dat file.. please help!!

allend 09-27-2016 07:09 PM

If you just want to remove the text from the file to leave the numbers:
Code:

sed 's/[^ ]*=//g' file.dat

John VV 09-27-2016 09:02 PM

also WHAT software are you using ?
and what language is it in ?
python ?
perl ?
m( matlab) ?
FORTRAN ?

or are you using a spreadsheet program ?

or just the terminal only and bash scripting it ?

i could go on GUESSING!!!!!!

but you need to fill in the blanks

wpeckham 09-27-2016 09:32 PM

Feed me! Feed me DATA!
 
Agree with above, you need to feed us enough information for us to understand what you are going to need.

If my program returned a data file like that, with no time stamp or sequence number, I would be ashamed.
GNUPLOT could be used to extract and plot data for that format, but it would be slightly ugly. There is no way to reorder the data and reliably maintain any interesting kind of relationships, so the current order must be preserved.

From whence came this data?

John VV 09-27-2016 10:42 PM

for a output like you posted
Libreoffice's Calc will do

import it as a CSV and make a graph

aragorn2101 09-28-2016 03:52 AM

Hi,

If there were only numbers in two distinct columns, it could have been plotted easily with gnuplot at the command line.

Provided you have gnuplot, you could do:
Code:

$ gnuplot
gnuplot> plot "FILE.dat" with line

Or, of course, if you have an office suit, you could use a spreadsheet software to do the plot.

usamaAkhtar 09-28-2016 11:20 AM

@ john VV

I am using geany as IDE. language is C. the values are of four different channels from MCP3208 which give them to pi and pi apply certain features like MAV and RMS etc to these values which are saved in .dat/.csv file. i have to plot them seperately but as they are in same column so gnuplot is taking all of them plotting a single graph which of no use... i have to chnage them into four diffrent columns. i have tried changing loops but vain....

John VV 09-28-2016 12:12 PM

then use a spreadsheet

calc ( excel) can do many things -- even play space invaders using the cells

tofino_surfer 10-01-2016 05:32 AM

There is a major problem with

sed 's/[^ ]*=//g' file.dat

in that it will remove the space between the columns creating one number for each line. For ex:

channels=1 Voltage=1.82
channels=2 Voltage=0.34

would become

11.82
20.34

You would need to either keep the space or replace it with a comma.

sed -e 's/^*=//g' -e 's/[ ]*=/,/g' file.dat

The above would work if my sed syntax is correct. The first rule matches the newline and removes everything. The second matches the space between columns and replaces it with a comma. You should get

1,1.82
2,0.34

allend 10-01-2016 05:53 AM

From 'info sed'
Quote:

`[LIST]'
`[^LIST]'
Matches any single character in LIST: for example, `[aeiou]'
matches all vowels. A list may include sequences like
`CHAR1-CHAR2', which matches any character between (inclusive)
CHAR1 and CHAR2.

A leading `^' reverses the meaning of LIST, so that it matches any
single character _not_ in LIST. To include `]' in the list, make
it the first character (after the `^' if needed), to include `-'
in the list, make it the first or last; to include `^' put it
after the first character.
so 's/[^ ]*=//g' matches the non-space characters and the '=', and replaces them with nothing, for every occurrence in the line. The space character is preserved, so no major problem.


All times are GMT -5. The time now is 04:43 PM.