LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-27-2009, 12:47 PM   #1
since1993
Member
 
Registered: Aug 2009
Location: Seoul in Korea
Distribution: Debian 5.0.2 lenny
Posts: 36
Blog Entries: 2

Rep: Reputation: 16
Question convert tab separated file to simple X-Y chart


I wrote a script which analysis apache logs. This script generates a tab separated data file. There is two columns in the data. The first column is a file name accessed from remote. The second column shows how many times a file access.

The data file looks like below

[data file]
index.html 352
logo.jpg 422
introduction 34


I am looking for a linux command drawing a chart corresponding data.

PS> of course, I know that I can draw the chart in OpenOffice Calc. That's not what I need. Because there is some steps to do for a simple chart drawing. If there is a command line tool, then I can write a script that drawing a chart when the data file is updated.
 
Old 08-27-2009, 01:12 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
I'm not sure what exactly you're trying to do, but with
"drawing a graph" and "command line" gnuplot spings to
mind ... maybe completely wrong, and not what you're
after. Of course there's also GD - can be used nicely
from PHP scripts (possibly other languages too, but I
only remember PHP of the top of my head).



Cheers,
Tink
 
Old 08-27-2009, 02:09 PM   #3
since1993
Member
 
Registered: Aug 2009
Location: Seoul in Korea
Distribution: Debian 5.0.2 lenny
Posts: 36

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Question Bar-chart utility

I have a data file. I want to draw a bar chart using the data file. I am looking for a linux program which can do this.

The data file contains two data. One is file names. The other one is size of the file.

[filesize.dat]
a 21
b 4
c 27

a, b and c are file names. The numbers are size of those files in kilobytes. X axis is file name. Y axis is file size. Of course, I can bring data file into OpenOffice Calc and use Chart tool. However, I have to look this graph very often. I need a linux program simply draw bar-chart.

COMMAND filesize.dat --bar_style

It would be great if I can see the simple graph with a command like above. Is there any program like this?

PS> it is hard for me to learn OOo BASIC programming or to learn gnuplot.
 
Old 08-27-2009, 02:23 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
I've merged your two *VERY* closely related threads.
 
Old 08-27-2009, 03:09 PM   #5
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
This is the original data file:

$ cat filesize.dat
Code:
index.html 352
logo.jpg 422
introduction 34
This is a script preparing data for gnuplot:

$ cat script.sh
Code:
#!/bin/sh

IFS.old=$IFS
IFS='
'

declare -i n=0
> filesize.numbered.dat
> filesize.numbered.gnuplot.dat

for line in `cat filesize.dat`
do
    n=$n+1
    echo "$n $line" >> filesize.numbered.dat
    echo "$n `echo $line | awk '{print $2}'`" >> filesize.numbered.gnuplot.dat
done
This is human readable output with numbered lines:

$ cat filesize.numbered.dat
Code:
1 index.html 352
2 logo.jpg 422
3 introduction 34
This is gnuplot readable output with numbered lines but without file’s names:

$ cat filesize.numbered.gnuplot.dat
Code:
1 352
2 422
3 34
This is the session with gnuplot:

$ gnuplot
Code:
$ gnuplot 
gnuplot> set terminal png color
gnuplot> set output 'filesize.numbered.gnuplot.png'
gnuplot> plot 'filesize.numbered.gnuplot.dat' with lines
gnuplot> quit
This is your chart: filesize.numbered.gnuplot.png.

I don't insist it's the simplest solution. Someone can suggest something simpler or more elegant.
 
Old 08-27-2009, 03:18 PM   #6
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
This is another way of number lines and remove file's names:

$ grep -n '' filesize.dat | sed 's/:/ /'

$ grep -n '' filesize.dat | sed 's/:/ /' | awk '{print $1,$3}'
 
Old 08-27-2009, 06:07 PM   #7
since1993
Member
 
Registered: Aug 2009
Location: Seoul in Korea
Distribution: Debian 5.0.2 lenny
Posts: 36

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Wink Thank you....

Thank you for helping me.
I would like to show the file names for each bars. Since files keep being added, edited and deleted, I thought I have to write a scipt to label each bars.

I found another solution at `http://www.burningcutlery.com/derek/bargraph/. Somebody already wrote a perl script. And, I could finish my job.

I am a lazy man. I didn't like to spend a day or more to understand gunplot and to write a script generating customized gnuplot command file.

Last edited by since1993; 08-27-2009 at 06:10 PM.
 
  


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
convert columns to rows (tab separated file to csv) doug23 Programming 16 08-16-2009 09:14 PM
Parsing a comma separated CSV file where fields have commas in to trickyflash Linux - General 7 03-26-2009 03:30 PM
[SOLVED] Convert CSV to Tab imkornhulio Programming 7 11-15-2008 07:20 PM
help with comma separated values and what should be a simple script. zaber Programming 10 03-06-2008 12:58 PM
Reading comma-separated data from file MeLassen Programming 4 04-04-2004 02:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:24 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