2
I have a text file of lecture topics from my physics class that looks like this:
1/14,Galilean relativity,Einsteinian relativity,Minkowski space,Henri Poincare,,
1/16,Lorentz transformations,Velocity transformations,Proper time,Light aberration,Lorentz tensors formalism,Minkowski space
1/23,Lorentz boost,Lorentz group,Poincare group,contravariant tensor,covariant tensor,d'Alembertian
I actually store it as Google Doc, so I could export it as a tsv, ods, xslx, etc. instead of a csv.
I want to generate an index like you would see in the back of a book, listing the topics alphabetically by date, e.g.
d'Albertian 1/23
... (more entries)
Minkowski space 1/14 1/16
... (more entries)
Velocity transformations 1/16
or if you want to get fancy:
d'Albertian ................. 1/23
... (more entries)
Minkowski space ............. 1/14, 1/16
... (more entries)
Velocity transformations .... 1/16
I first thought of using LaTeX
, but the indexing packages all seem to go by page number, not an arbitrary string like a date. In fact, "MakeIndex assumes that all page numbers are either arabic or lower-case roman numerals;" http://www.tex.ac.uk/ctan/indexing/makeindex/doc/makeindex.pdf.
Moreover, the input file for makeindex
must be a list with one topic and page number per line; it just does the sorting and formatting: http://www.troubleshooters.com/linux/lyx/makeindex.htm
So, the software I am looking for needs to do this:
- Accept a csv, tsv, or other spreadsheet format.
This would be ideal, but I would be ok with a text format that could be fairly easily generated from a spreadsheet file, e.g. by substitutions with
awk
orsed
. - Associate the first entry of each line (e.g. the date
1/14
) with each of the following entries (e.g. the topicsGalilean relavity
,Minkowski space
, etc.). - Sort all the topics for all the dates alphabetically.
- Combine the topics that show up more than once into a single entry, listing every date that the topic shows up in.
- Output the result as a standard format.
My only requirement for the software is that it run on Linux.
I'm not fussy about output format; text file, LaTeX, HTML, odf, etc. are all fine by me, as long as I can print out a paper copy.
I had trouble compiling from source, so I installed the package here: [http://fsxplat.codeplex.com/releases/view/55463]. It says
error FS0222: Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'
– Nathaniel M. Beaver – 2013-04-26T02:00:44.587try adding "module program" to the top of the file (no quotes) – jizugu – 2013-04-26T02:07:18.233
generate-index.fs(22,41): error FS0001: This expression was expected to have type string [] but here has type seq<string>
– Nathaniel M. Beaver – 2013-04-26T02:30:17.837Here's line 22:
let datestr = String.Join (", ",dates)
.dates
is at position (22,41) – Nathaniel M. Beaver – 2013-04-26T02:31:48.953try: let datestr = String.Join (", ",dates |> Seq.toArray) – jizugu – 2013-04-26T02:51:41.733
That works! I also changed the last line to
let datestr = String.Join (", ",dates |> Seq.toArray)
and now it outputs correctly. – Nathaniel M. Beaver – 2013-04-26T02:58:58.177