You are not logged in.

#1 2009-03-30 21:39:34

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

I need some help: Sort CSV data and plot to latex tabular.

I have given myself this task as a challenge and to help my coworkers.

In my workplace we have a monthly work schedule which is a bit complex and quite frankly not very nice to look at. My idea is to take this schedule, which is created in Excel, extract the data to csv and plot each employees schedule to a nice looking latex template I have created and thereby creating good looking schedule for each employee and automatically mailing it to them. The csv bit was easy and creating the template was fun (I like texing).

The next part is where I'm a bit lost. Which tools are best for these kinds of tasks?

1. Perl, but are there any suitable modules for these kinds of task already?
2. Python?
3. A conglomerate of linux tools and bash scripts?
4. Something completly different?

Here is an excerpt of the csv file:

"Uge 15","07-Apr","08-Apr","09-Apr","10-Apr","11-Apr","12-Apr","13-Apr",
"MØDETID","Man","Tirs","Ons","Tors","Fre","Lør","Søn",
"7:30-15:30","TRAP","TRAP","XXXX",,,,,"Supervisor"
"7:30-15:30","FBCO","FBCO","FBCO",,,,,"Supervisor"
"MØDETID","DAGVAGTER",,,,,,,"FROKOST",
"5:50-13:40","XXXX","XXXX","XXXX",,,,,"11.00-11.45",
"6:50-14:40","BNOT","PRSK","SNAH",,,,,
"6:50-14:40","PVSJ","PVSJ","ARAP",,,,,
"6:50-14:40",,,,,,,,
"7:20-15:10","SNAH","NXTS","LMVG",,,,,
"7:20-15:10",,,,,,,,
"7:50-15:40","PRSK","LMVG","NXTS",,,,,"11.45-12.30",,,,,,,
"7:50-15:40","LNAJ","BNOT","NMBJ",,,,,
"7:50-15:40",,,"TOMD",,,,,
"7:50-15:40",,,,,,,,
"8:20-16:10",,,"PRSK",,,,,"12.30-13.15"
"9:10-17:00","LMVG","ARAP","BNOT",,,,,
"9:10-17:00","JKMB","LNAJ","JKMB",,,,,
"9:10-17:00",,,,,,,,
"MØDETID","DEP. ADM",,,,,,,"FROKOST",
"7:50-15:40","ARAP","SNAH","LNAJ",,,,,"11.45-12.30"
"8:50-16:40","NXTS","JKMB","PVSJ",,,,,"12.30-13.15"
"MØDETID","SÆRLIGE VAGTER",,,,,,,"FROKOST",
"8:50-14:30","-","-","-",,,,,"11.45-12.30"
"8:50-14:00","-","-","-",,,,,
"FLEXIBEL","KHOS","KHOS","KHOS",,,,,"SMS VAGT"
"FLEXIBEL","SQLZ","SQLZ","SQLZ",,,,,"SMS VAGT"
"FLEXIBEL","RAGJ","RAGJ","RAGJ",,,,,"SMS/CORP_IT"
"MØDETID","DEP. 1",,,,,,,
"6:50-15:05",,,,,,"JMKB","JMKB","24/7 Morgen"
"13:50-22:05","GRTA","GRTA","GRTA","GRTA","GRTA",,,"24/7 Aften 1"
"14:50-23:05","SPAL","SPAL","SPAL","SPAL","SPAL","SNAH","SNAH","24/7 Aften 2"
"6:50-15:05",,,,,,"SQLZ","SQLZ","24/7 Rådighed"
"14.50-23:05","SQLZ","SQLZ","SQLZ","SQLZ","SQLZ","SQLZ","SQLZ","24/7 Rådighed"
"24/7 Fri","TOMD, NMBJ","TOMD, NMBJ",,,"SNAH, JKMB",,,"24/7 Fri"

The four letter combinations i.e. "RAGJ" are the employees initials (changed here of course). The above excerpt is for week 15.

Below is an excerpt of latex template I've created:

\documentclass[12pt,a4paper]{article}
\usepackage[danish]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\pagenumbering{gobble}
\title{}
\lhead {\includegraphics[scale=0.5]{/home/edgar/job/cslogo_1_.jpg}}
\rhead{\begin{footnotesize}Dato: \today \end{footnotesize}}
\rfoot{\begin{tiny}Af Ashren - Skrevet i \LaTeX \end{tiny}}
\begin{document}
\begin{center}
\begin{tabular}{||c||c|c|c|c|c|c|c||}
\hline
\multicolumn{8}{||c||}{\textbf Uge 15 - 6-12 april} \\
\hline  Tid & Man & Tir & Ons & Tors & Fre & Lør & Søn \\ 
\hline  5.50-13.40 &  &  &  &  &  &  &  \\ 
\hline  6.50-14.40 &  &  &  &  &  &  &  \\ 
\hline  8.20-16.10 &  &  &  &  &  &  &  \\
\hline  7.20-15.10 &  &  &  &  &  &  &  \\
\hline  7.50-15.40 &  &  &  &  &  &  &  \\ 
\hline  8.50-16.40 &  &  &  &  &  &  &  \\ 
\hline  9.20-17.00 &  &  &  &  &  &  &  \\ 
\hline  13.50-22.05 & &  &  &  &  &  &  \\ 
\hline  14.50-23.05 &  &  &  &  &  &  &  \\ 
\hline 
\end{tabular}
\end{center}
\end{document}

What I need is to extract each employees data and plot their work hours using the letter "X" in to the tabular.

Can someone point me in the right direction?

Thanks

Ashren.

Last edited by Ashren (2009-03-30 21:41:24)

Offline

#2 2009-03-30 22:07:46

tam1138
Member
Registered: 2007-09-10
Posts: 238

Re: I need some help: Sort CSV data and plot to latex tabular.

Python, Perl, and shell scripts will all do what you want, along with a host of other languages.  Your project is more suited to the interpreted, text-processing languages (eg, the ones you suggested) as opposed to a big, unwieldy compiled language like C.  Your needs are almost certainly specific enough to justify rolling your own solution; I wouldn't bother searching out an existing module.  Additionally, you'll learn more by rolling your own. smile

I don't have any specific guidance regarding language, except to say that it will be easier in Python or Perl or the like as opposed to shell scripts.  I suggest you pick one arbitrarily and just do it.  If you want to get really fancy, after you're done, pick another and re-implement it to see how the languages differ in the tools they provide you for solving problems like these.

Good luck!

Offline

#3 2009-03-30 23:39:35

area
Member
Registered: 2008-09-18
Posts: 43

Re: I need some help: Sort CSV data and plot to latex tabular.

looks like regular expression and python dictionaries are about to be your best friends... a dictionary is just a fancy array that allows you to refference the data by an index or, inversely, the index by the data. 

http://diveintopython.org/native_data_t … elper.dict
to learn about dictionaries. Dive Into Python is very highly renowed for a beginners guide to python.

http://python.net/crew/bhoel/PyLaTeX-0. … LaTeX.html
for an interesting looking interface between latex and python  (your mileage my vary)

I would not have normally done the googling for you but it just so happends that this will help me in my own pursuits.

good luck and let us know how it works out.... seems like a very useful project

Offline

#4 2009-03-31 00:19:29

tam1138
Member
Registered: 2007-09-10
Posts: 238

Re: I need some help: Sort CSV data and plot to latex tabular.

Whoa, hey now.  Regular expressions are way overkill.  He just needs to split a string using a delimiter.

Offline

#5 2009-03-31 02:07:27

area
Member
Registered: 2008-09-18
Posts: 43

Re: I need some help: Sort CSV data and plot to latex tabular.

good point.... but its fun to "kill a mosquito with a cannon" sometimes

Offline

#6 2009-03-31 04:43:35

dw
Member
From: Vienna, Austria
Registered: 2006-11-25
Posts: 160

Re: I need some help: Sort CSV data and plot to latex tabular.

Hi. I would read the data using R and create a fancy output using the sweave-plugin. should be the easiest way.

Offline

#7 2009-03-31 07:06:43

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: I need some help: Sort CSV data and plot to latex tabular.

Thank you for the advice guys. I'll think I'll use Python to start out with and see if I can produce something that does what I want - thanks tam1138 and area.

dw: R + sweave looks interesting to say the least, but I can't really decide if it may be overkill. I'll look into it some more.

I'll report back as soon as I have something that works.

Last edited by Ashren (2009-03-31 07:09:18)

Offline

Board footer

Powered by FluxBB