Initial state
This commit is contained in:
commit
3253d8c94f
137
beitragsquittung.rb
Executable file
137
beitragsquittung.rb
Executable file
|
@ -0,0 +1,137 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'cmxl' # for parsing the MT940 file
|
||||
require 'roo' # for parsing the Excel file
|
||||
require 'humanize' # for converting numbers to words
|
||||
|
||||
Humanize.configure do |config|
|
||||
config.default_locale = :de # [:en, :es, :fr, :tr, :de, :id], default: :en
|
||||
config.decimals_as = :number # [:digits, :number], default: :digits
|
||||
end
|
||||
|
||||
# usage ./beitragsquittung.rb <MT940 file> <Excel file> <member id>
|
||||
# the member ID is optional. If not provided, all members are processed
|
||||
# the time range is used from the MT940 file
|
||||
|
||||
def generate_reciept(mitgliedsnummer, name, vorname, strasse, hausnummer, plz, ort, betrag, betrag_in_worten, start_datum, end_datum, payments)
|
||||
puts "Generating reciept for #{mitgliedsnummer} #{name} #{vorname} #{strasse} #{hausnummer} #{plz} #{ort} #{betrag} #{betrag_in_worten} #{start_datum} #{end_datum}"
|
||||
|
||||
# create a csv file with the payments
|
||||
CSV.open("payments.csv", "wb") do |csv|
|
||||
csv << ["datum", "betrag", "type", "verzicht"]
|
||||
payments.each do |payment|
|
||||
csv << [payment[:date], payment[:amount], payment[:type], payment[:verzicht]]
|
||||
end
|
||||
end
|
||||
|
||||
# call latex to generate the pdf
|
||||
system("pdflatex \"\\newcommand{\\vorname}{#{vorname}} \\newcommand{\\nachname}{#{name}} \\newcommand{\\strasse}{#{strasse + " " + hausnummer.to_s}} \\newcommand{\\plz}{#{plz}} \\newcommand{\\ort}{#{ort}} \\newcommand{\\betrag}{#{betrag}} \\newcommand{\\betraginworten}{#{betrag_in_worten}} \\newcommand{\\startdatum}{#{start_datum}} \\newcommand{\\findatum}{#{end_datum}} \\newcommand{\\mitgliedsnummer}{#{mitgliedsnummer}} \\input{document.tex}\"")
|
||||
end
|
||||
|
||||
def get_payments_from_member_id(mitgliedsnummer)
|
||||
|
||||
Cmxl.config[:statement_separator] = /\n-.\n/m
|
||||
Cmxl.config[:raise_line_format_errors] = true
|
||||
|
||||
# get the filename from the command line arguments
|
||||
filename = ARGV[0]
|
||||
|
||||
# check if the filename is valid or not presented
|
||||
if filename.nil? || !File.exists?(filename)
|
||||
puts "Enter the filename of the MT940 statement to parse"
|
||||
filename = gets.chomp
|
||||
end
|
||||
|
||||
# parse the MT940 file
|
||||
statements = Cmxl.parse(File.read(filename), :encoding => 'ISO-8859-1')
|
||||
|
||||
# The statement contains transactions called Mitgliedsbeitrag. They are labled like this: "MREF"=>"Mitgliedsbeitrag Nr. 17" where 17 is the mitgliedsnummer.
|
||||
# for each payment of the mitgliedsbeitrag create an entry with the date and amount in the following datastructure
|
||||
payments = []
|
||||
|
||||
statements.each do |s|
|
||||
s.transactions.each do |t|
|
||||
reference = ""
|
||||
t.sepa.each do |sf|
|
||||
# add the second entry of the sepa reference (sf) to the reference string if the first entry contans "MREF"
|
||||
if sf[0] == "MREF"
|
||||
reference = sf[1]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# if the mitgliedsnummer is a single digit number, the reference is "Mitgliedsbeitrag Nr. 01" and not "Mitgliedsbeitrag Nr. 1"
|
||||
# so we have to check for both cases
|
||||
if reference.include?("Mitgliedsbeitrag Nr. #{mitgliedsnummer.to_s.rjust(2, '0')}") || reference.include?("Mitgliedsbeitrag Nr. #{mitgliedsnummer}")
|
||||
# puts t.entry_date
|
||||
# puts t.amount
|
||||
payment = {
|
||||
date: t.entry_date,
|
||||
amount: t.amount,
|
||||
type: "Mitgliedsbeitrag",
|
||||
verzicht: "nein"
|
||||
}
|
||||
payments << payment
|
||||
# puts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# get the start and end date of the statements
|
||||
start_datum = statements[0].opening_balance.date.strftime("%d.%m.%Y")
|
||||
end_datum = statements[statements.length() -1].closing_balance.date.strftime("%d.%m.%Y")
|
||||
|
||||
return payments, start_datum, end_datum
|
||||
end
|
||||
|
||||
def get_member_details_from_mitgliedsnummer(mitgliedsnummer)
|
||||
# get the member details from the excel file
|
||||
# the member details are stored in the first sheet
|
||||
# the first row contains the headings of the columns
|
||||
# the second row contains the values for the first member
|
||||
# the headings are: Nr., Nachname, Vorname, Geburtsdatum, Straße, Hausnummer, Postleitzahl, Ort
|
||||
# the values are: 1, Mustermann, Max, 01.01.1970, Musterstraße, 1, 12345, Musterstadt
|
||||
xlsx = Roo::Spreadsheet.open(ARGV[1])
|
||||
|
||||
# create data structure
|
||||
member = {
|
||||
name: xlsx.sheet(0).row(mitgliedsnummer+1)[1],
|
||||
vorname: xlsx.sheet(0).row(mitgliedsnummer+1)[2],
|
||||
strasse: xlsx.sheet(0).row(mitgliedsnummer+1)[4],
|
||||
hausnummer: xlsx.sheet(0).row(mitgliedsnummer+1)[5],
|
||||
plz: xlsx.sheet(0).row(mitgliedsnummer+1)[6],
|
||||
ort: xlsx.sheet(0).row(mitgliedsnummer+1)[7]
|
||||
}
|
||||
return member
|
||||
end
|
||||
|
||||
mitgliedsnummer = ARGV[2].to_i
|
||||
if mitgliedsnummer.nil?
|
||||
# get number of members from the excel file it is the first value of the last row
|
||||
xlsx = Roo::Spreadsheet.open(ARGV[1])
|
||||
anzahl_members = xlsx.sheet(0).last_row[0]
|
||||
puts "Number of members: #{anzahl_members}"
|
||||
|
||||
# loop over all members
|
||||
for mitgliedsnummer in 1..anzahl_members
|
||||
puts "Processing member #{mitgliedsnummer}"
|
||||
get_payments_from_member_id(mitgliedsnummer)
|
||||
generate_reciept(mitgliedsnummer, name, vorname, strasse, plz, ort, betrag, betrag_in_worten, start_datum, end_datum)
|
||||
end
|
||||
else
|
||||
# get the payments from the MT940 file
|
||||
payments, start_datum, end_datum = get_payments_from_member_id(mitgliedsnummer)
|
||||
puts "Payments:"
|
||||
total_payment = 0
|
||||
payments.each do |payment|
|
||||
puts payment[:date] + " " + payment[:amount].to_s
|
||||
total_payment += payment[:amount]
|
||||
end
|
||||
|
||||
# convert the total payment to a string in german
|
||||
betrag_in_worten = total_payment.humanize
|
||||
puts "Total payment:" + total_payment.to_s + " in worten: " + betrag_in_worten
|
||||
puts
|
||||
|
||||
member = get_member_details_from_mitgliedsnummer(mitgliedsnummer)
|
||||
generate_reciept(mitgliedsnummer, member[:name], member[:vorname], member[:strasse], member[:hausnummer], member[:plz], member[:ort], total_payment, betrag_in_worten, start_datum, end_datum, payments)
|
||||
end
|
421
csvsimple/CHANGES.md
Normal file
421
csvsimple/CHANGES.md
Normal file
|
@ -0,0 +1,421 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on
|
||||
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to
|
||||
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
### Changed
|
||||
### Deprecated
|
||||
### Removed
|
||||
### Fixed
|
||||
### Security
|
||||
|
||||
|
||||
## [2.5.0] - 2023-10-16
|
||||
|
||||
### Added
|
||||
- New survey tables (issue #29):
|
||||
- `\csvautotabularray`
|
||||
- `\csvautotabularray*`
|
||||
- `\csvautolongtabularray`
|
||||
- `\csvautolongtabularray*`
|
||||
- New corresponding options (issue #29)
|
||||
- `autotabularray`
|
||||
- `autotabularray*`
|
||||
- `autolongtabularray`
|
||||
- `autolongtabularray*`
|
||||
|
||||
### Changed
|
||||
- Documentation typos fixed (issue #30)
|
||||
- Survey tables moved into a separate section
|
||||
|
||||
### Fixed
|
||||
- `collect data` does not collect `after first line` (issue #28)
|
||||
|
||||
|
||||
|
||||
## [2.4.0] - 2023-05-09
|
||||
|
||||
### Added
|
||||
- New additive filter options (issue #24):
|
||||
- `and filter bool`
|
||||
- `and filter fp`
|
||||
- `and filter strcmp`
|
||||
- `and filter not strcmp`
|
||||
- `or filter bool`
|
||||
- `or filter fp`
|
||||
- `or filter strcmp`
|
||||
- `or filter not strcmp`
|
||||
- Hook `csvsimple/csvline` added with example for doublequote replacement (issue #19)
|
||||
- Option setting `separator = space` (issue #20)
|
||||
|
||||
### Changed
|
||||
- The content of `range` is now expanded before processing it
|
||||
- Implementation of `filter bool`, `filter fp`, `filter strcmp`, `filter not strcmp`
|
||||
|
||||
|
||||
|
||||
## [2.3.2] - 2022-09-20
|
||||
|
||||
### Fixed
|
||||
- The `\ifcsvfirstrow` command doesn't work (issue #23)
|
||||
|
||||
|
||||
|
||||
## [2.3.1] - 2022-06-21
|
||||
|
||||
### Fixed
|
||||
- Documentation: placeholder names corrected (issue #21)
|
||||
- Use built-in constants instead of integers for boolexpr (issue #22)
|
||||
|
||||
|
||||
|
||||
## [2.3.0] - 2022-02-01
|
||||
|
||||
### Added
|
||||
- Option `column names detection` (related to issue #16)
|
||||
- Documentation: csvautotabular inspired example for tabularray.
|
||||
|
||||
### Changed
|
||||
- `\csvlinetotablerow` changed to be expandable and to be
|
||||
usable inside a *Data Collection* (issue #16)
|
||||
- Options `autotabular`, `autobooktabular`, `autolongtable`, `autobooklongtable`
|
||||
use `column names detection=false` now.
|
||||
|
||||
|
||||
|
||||
## [2.2.1] - 2022-01-07
|
||||
|
||||
### Fixed
|
||||
- Option `late after first line` ignored for `csvsimple-l3` (issue #17)
|
||||
|
||||
|
||||
|
||||
## [2.2.0] - 2021-09-09
|
||||
|
||||
### Added
|
||||
- Configurable usage of tabular-like environments (issue #12)
|
||||
- Option `table centered`
|
||||
- Option `generic table`
|
||||
- Option `generic collected table`
|
||||
- Option `generic table options`
|
||||
|
||||
### Changed
|
||||
- The implementation of all tabular-like environments uses the new
|
||||
generic environments now internally. Should be unnoticeable for a user.
|
||||
|
||||
### Fixed
|
||||
- documentation typo correction and small improvents (issue #15)
|
||||
- Option `long tabularray`
|
||||
|
||||
|
||||
|
||||
## [2.1.0] - 2021-07-06
|
||||
|
||||
### Added
|
||||
- Support for (limited) data collection (issue #15)
|
||||
- Support for package `tabularray` (part of issue #12)
|
||||
- Option `after filter`
|
||||
- Option `collect data`
|
||||
- Option `data collection`
|
||||
- Option `tabularray`
|
||||
- Option `centered tabularray`
|
||||
- `\csvdatacollection`
|
||||
- `\csvexpval`
|
||||
- `\csvexpnot`
|
||||
- `\csvcollectn`
|
||||
- `\csvcollectx`
|
||||
- `\csvcollectV`
|
||||
|
||||
### Fixed
|
||||
- Line Range was not resetted
|
||||
- Wrong link and word inside documentation `csvsimple.pdf` (issue #13, issue #15)
|
||||
- Several inconsistent local/global assignment errors
|
||||
|
||||
|
||||
|
||||
## [2.0.0] - 2021-06-29
|
||||
|
||||
### Added
|
||||
- New documentation `csvsimple-l3.pdf` for the new LaTeX3 version
|
||||
(revised, adapted and extended from the old documentation)
|
||||
- `\thecsvcolumncount`
|
||||
- Option `autotabular*`
|
||||
- Option `autobooktabular*`
|
||||
- Option `autolongtable*`
|
||||
- Option `autobooklongtable*`
|
||||
- Option `filter bool`
|
||||
- Option `filter fp`
|
||||
- Option `range`
|
||||
- `\csvautotabular*`
|
||||
- `\csvautobooktabular*`
|
||||
- `\csvautolongtable*`
|
||||
- `\csvautobooklongtable*`
|
||||
- `\csvfilterbool`
|
||||
- `\ifcsvfirstrow`
|
||||
- `\ifcsvoddrow`
|
||||
- `\ifcsvfpcmp`
|
||||
- `\ifcsvintcmp`
|
||||
- `\csvsortingrule`
|
||||
|
||||
### Changed
|
||||
- Complete re-implementation of the hitherto existing latex package
|
||||
as LaTeX3 package using the expl3 interface. From now on, three package
|
||||
files are provided:
|
||||
** `csvsimple-legacy.sty` identical to csvsimple until version 1.22 **
|
||||
** `csvsimple-l3.sty` LaTeX3 package of csvsimple **
|
||||
** `csvsimple.sty` stub to select `l3` or `legacy` (default) **
|
||||
- The LaTeX2e version (`csvsimple-legacy`) will be maintained in its
|
||||
current state with no intended changes with exceptions of bug fixes.
|
||||
- The LaTeX3 version (`csvsimple-l3`) is regarded to be the main package
|
||||
and may receive feature upgrades in the future
|
||||
- Existing documents using csvsimple v1.22 need no change since loading
|
||||
`csvsimple` will load `csvsimple-legacy`.
|
||||
- `cvsimple-l3` is a *nearly* drop-in replacement for `csvsimple-legacy`.
|
||||
Only very few things phased out and the user interface is quite identical.
|
||||
The most significant difference is that `l3keys` are used instead of `pgfkeys`
|
||||
which may need adaptions on user side (for examples, if .styles are used)
|
||||
- New documents are encouraged to apply `cvsimple-l3` instead of `csvsimple-legacy`.
|
||||
- For the complete package is valid: do not upgrade from version 1.22, if your
|
||||
TeX installation has no current LateX3/expl3 support a.k.a *is too old*
|
||||
- `csvinputline` and `csvrow` are no longer LaTeX2e counters
|
||||
- The hitherto existing documentation `csvsimple.pdf` is now `csvsimple-legacy.pdf`
|
||||
- `csvsimple.pdf` documents the stub package and differences
|
||||
between `csvsimple-l3.sty` and `csvsimple-legacy.sty`
|
||||
- `column count = 0` means automatic column number detection for CSV files without head
|
||||
- Option `head` does not change option `check column count` anymore
|
||||
- Changelog moved from CHANGES to CHANGES.md and adapted to
|
||||
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
- From now on version numbers adhere to
|
||||
[Semantic Versioning](http://semver.org/spec/v2.0.0.html)
|
||||
|
||||
### Deprecated
|
||||
- `\csviffirstrow`
|
||||
- `\csvifoddrow`
|
||||
|
||||
### Removed
|
||||
- `\csvheadset`
|
||||
- Option `filter`
|
||||
- Option `nofilter`
|
||||
- Option `nohead`
|
||||
|
||||
|
||||
|
||||
## [1.22] - 2021-06-07
|
||||
|
||||
### Added
|
||||
- Option `head to column names prefix` (issue #7)
|
||||
|
||||
### Changed
|
||||
- Due to changes in the LaTeX kernel 2021-06-01, the empty line
|
||||
detection of csvsimple had to be adapted. Updating csvsimple is
|
||||
essential to avoid problems with kernel 2021-06-01. (issue #11)
|
||||
|
||||
|
||||
|
||||
## [1.21] - 2019-04-09
|
||||
|
||||
### Changed
|
||||
- Package `pgfrcs` added as required package
|
||||
- Introduction augmented with additional hints for first time users (issue #3)
|
||||
|
||||
### Fixed
|
||||
- Spurious blank in sorting code removed
|
||||
|
||||
|
||||
|
||||
## [1.20] - 2016-07-01
|
||||
|
||||
### Added
|
||||
- New string comparison macros:
|
||||
- `\ifcsvstrequal`
|
||||
- `\ifcsvprostrequal`
|
||||
- `\ifcsvstrcmp`
|
||||
- `\ifcsvnotstrcmp`
|
||||
- New filter options:
|
||||
- Option `filter ifthen`
|
||||
- Option `filter test`
|
||||
- Option `filter expr`
|
||||
- Option `full filter`
|
||||
- Option `filter strcmp`
|
||||
- Option `filter not strcmp`
|
||||
|
||||
### Changed
|
||||
- Implementation changed from `\roman` to `\romannumeral`
|
||||
- `\write18` replaced by `\ShellEscape` from the shellesc package
|
||||
- `\csvlinetotablerow` implemented more efficiently
|
||||
- `\csvloop` made long
|
||||
- Code optimizations
|
||||
- Documentation revised
|
||||
|
||||
|
||||
|
||||
## [1.12] - 2014-07-14
|
||||
|
||||
### Added
|
||||
- Option `csvsorter token`
|
||||
- Documentation extended with siunitx examples
|
||||
|
||||
### Changed
|
||||
- Success of CSV-Sorter call is checked (Note: Update to CSV-Sorter v0.94 or newer!)
|
||||
- Encircling column entry braces removed for all entries for better siunitx compatibility
|
||||
- Documentation revised
|
||||
|
||||
### Fixed
|
||||
- CSV-Sorter call incompatibilities with the ngerman package (not babel)
|
||||
|
||||
|
||||
|
||||
## [1.11] - 2014-07-08
|
||||
|
||||
### Changed
|
||||
- If a CSV file with an empty first line is found, csvsimple
|
||||
stops with an error message
|
||||
|
||||
### Fixed
|
||||
- Sorting preprocessor overwrites the input data in some combinations
|
||||
|
||||
|
||||
|
||||
## [1.10] - 2014-07-07
|
||||
|
||||
### Added
|
||||
- `\csvautobooktabular`
|
||||
- `\csvautobooklongtable`
|
||||
- External sorting specifically supported for the CSV-Sorter tool with the new options
|
||||
- Option `csvsorter command`
|
||||
- Option `csvsorter configpath`
|
||||
- Option `csvsorter log`
|
||||
- Option `sort by`
|
||||
- Option `new sorting rule`
|
||||
- New keys for respecting special characters:
|
||||
- Option `respect tab`
|
||||
- Option `respect percent`
|
||||
- Option `respect sharp`
|
||||
- Option `respect dollar`
|
||||
- Option `respect and`
|
||||
- Option `respect backslash`
|
||||
- Option `respect underscore`
|
||||
- Option `respect tilde`
|
||||
- Option `respect circumflex`
|
||||
- Option `respect leftbrace`
|
||||
- Option `respect rightbrace`
|
||||
- Option `respect all`
|
||||
- Option `respect none`
|
||||
- Option setting `separator = tab`
|
||||
|
||||
### Changed
|
||||
- If a CSV file is not found, csvsimple stops with an error message instead of a warning
|
||||
|
||||
### Fixed
|
||||
- Table head names in curly brackets were not recognized for some cases
|
||||
|
||||
|
||||
|
||||
## [1.07] - 2013-09-25
|
||||
|
||||
### Added
|
||||
- Option `separator` to set the data value separator to
|
||||
`comma`, `semicolon`, or `pipe`
|
||||
|
||||
### Changed
|
||||
- Internal macro `\TrimSpaces` renamed to avoid name clashed with `xparse`
|
||||
|
||||
|
||||
|
||||
## [1.06] - 2012-11-08
|
||||
|
||||
### Changed
|
||||
- Implementation for line breaking changed from full macro expansion to
|
||||
token expansion. This allows quite arbitrary macro code inside the data.
|
||||
Note that this may be a breaking change if your application expects
|
||||
expanded column values.
|
||||
- Option values added for `\csvautotabular` and `\csvautolongtable`
|
||||
|
||||
|
||||
|
||||
## [1.05] - 2012-03-12
|
||||
|
||||
### Added
|
||||
- Source code of the documentation added
|
||||
- Provision of the csvsimple.tds.zip file for easier installation
|
||||
- Option `preprocessed file`
|
||||
- Option `preprocessor`
|
||||
- Option `no preprocessing`
|
||||
|
||||
### Changed
|
||||
- Documentation language changed from German to English
|
||||
- Option `nocheckcolumncount` renamed to `no check column count`
|
||||
- Option `nofilter` renamed to `no check column count`
|
||||
- Option `nocheckcolumncount` renamed to `no filter`
|
||||
- Option `nohead` renamed to `no head`
|
||||
|
||||
### Deprecated
|
||||
- Option `nofilter`
|
||||
- Option `nohead`
|
||||
|
||||
### Removed
|
||||
- Option `@table` removed from the documentation
|
||||
|
||||
### Fixed
|
||||
- Error in `nocheckcolumncount` corrected and key renamed to 'no check column count'
|
||||
|
||||
|
||||
|
||||
## [1.04] - 2011-11-11
|
||||
|
||||
### Added
|
||||
- Option `head to column names` (automatic column names)
|
||||
- Option `no table`
|
||||
- Column numbers can now be used for column macro definitions
|
||||
|
||||
### Changed
|
||||
- Internal behaviour of `before reading` and `after reading`
|
||||
changed for tables
|
||||
|
||||
### Fixed
|
||||
- documentation update and correction
|
||||
|
||||
|
||||
|
||||
## [1.03] - 2011-11-04
|
||||
|
||||
### Fixed
|
||||
- Processing error for lines starting with '00' corrected
|
||||
|
||||
|
||||
|
||||
## [1.02] - 2011-04-04
|
||||
|
||||
### Added
|
||||
- `\csvfilteraccept`
|
||||
- `\csvfilterreject`
|
||||
- Option `filter accept all`
|
||||
- Option `filter reject all`
|
||||
|
||||
### Fixed
|
||||
- Error in the documentation for longtable und tabbing corrected
|
||||
|
||||
|
||||
|
||||
## [1.01] - 2010-11-10
|
||||
|
||||
### Added
|
||||
- Option `after first line`
|
||||
- Option `late after first line`
|
||||
- New example for key evaluation in the documentation
|
||||
|
||||
### Changed
|
||||
- Documentation of some options clarified
|
||||
|
||||
|
||||
|
||||
## [1.00] - 2010-07-28
|
||||
|
||||
### Added
|
||||
- Initial public release
|
62
csvsimple/README.md
Normal file
62
csvsimple/README.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
# The LaTeX package csvsimple - version 2.5.0 (2023/10/16)
|
||||
|
||||
|
||||
> Copyright (c) 2008-2023 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
|
||||
|
||||
> This work may be distributed and/or modified under the
|
||||
> conditions of the LaTeX Project Public License, either version 1.3
|
||||
> of this license or (at your option) any later version.
|
||||
> The latest version of this license is in
|
||||
> http://www.latex-project.org/lppl.txt
|
||||
> and version 1.3 or later is part of all distributions of LaTeX
|
||||
> version 2005/12/01 or later.
|
||||
|
||||
> This work has the LPPL maintenance status `author-maintained`.
|
||||
|
||||
> This work consists of all files listed in README.md
|
||||
|
||||
|
||||
`csvsimple` provides a simple *LaTeX* interface for the processing of files
|
||||
with comma separated values (CSV). `csvsimple` relies heavily on a key value
|
||||
syntax which results in an easy way of usage. Filtering and table generation
|
||||
is especially supported. Since the package is considered as a lightweight
|
||||
tool, there is no support for data sorting or data base storage.
|
||||
|
||||
|
||||
## Contents of the package
|
||||
|
||||
- `README.md` this file
|
||||
- `CHANGES.md` log of changes (history)
|
||||
- `csvsimple.sty` LaTeX package file (style file)
|
||||
- `csvsimple-l3.sty` LaTeX package file (style file)
|
||||
- `csvsimple-legacy.sty` LaTeX package file (style file)
|
||||
- `csvsimple.pdf` Documentation for csvsimple
|
||||
- `csvsimple-l3.pdf` Documentation for csvsimple (LaTeX3)
|
||||
- `csvsimple-legacy.pdf` Documentation for csvsimple (Legacy)
|
||||
- `csvsimple.tex` Source code of the documentation
|
||||
- `csvsimple-l3.tex` Source code of the documentation
|
||||
- `csvsimple-legacy.tex` Source code of the documentation
|
||||
- `csvsimple-doc.sty` Source code of the documentation
|
||||
- `csvsimple-title.png` Picture for the documentation
|
||||
- `csvsimple-example.tex` Example file for package usage
|
||||
- `csvsimple-example.csv` CSV file as part of the example
|
||||
- `csvsimple-example.pdf` Compiled example
|
||||
- `amountsort.xml` csvsorter configuration file (example)
|
||||
- `catsort.xml` csvsorter configuration file (example)
|
||||
- `encoding.xml` csvsorter configuration file (example)
|
||||
- `gradesort.xml` csvsorter configuration file (example)
|
||||
- `matriculationsort.xml` csvsorter configuration file (example)
|
||||
- `namesort.xml` csvsorter configuration file (example)
|
||||
- `transform.xml` csvsorter configuration file (example)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Copy the contents of the `csvsimple.tds.zip` from CTAN to your local TeX file tree.
|
||||
|
||||
Alternatively, put the files to their respective locations within the TeX installation:
|
||||
|
||||
- `csvsimple.sty` -> /tex/latex/csvsimple
|
||||
- `csvsimple-l3.sty` -> /tex/latex/csvsimple
|
||||
- `csvsimple-legacy.sty` -> /tex/latex/csvsimple
|
||||
- all other files -> /doc/latex/csvsimple
|
8
csvsimple/amountsort.xml
Normal file
8
csvsimple/amountsort.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<csv>
|
||||
<bracket empty="true" />
|
||||
<sortlines>
|
||||
<column name="amount" order="descending" type="double"/>
|
||||
<column name="land" order="ascending" type="string"/>
|
||||
</sortlines>
|
||||
</csv>
|
7
csvsimple/catsort.xml
Normal file
7
csvsimple/catsort.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<csv>
|
||||
<bracket empty="true" />
|
||||
<sortlines>
|
||||
<column name="cats" order="ascending" type="double"/>
|
||||
</sortlines>
|
||||
</csv>
|
115
csvsimple/csvsimple-doc.sty
Normal file
115
csvsimple/csvsimple-doc.sty
Normal file
|
@ -0,0 +1,115 @@
|
|||
% !TeX encoding=UTF-8
|
||||
%% The LaTeX package csvsimple - version 2.5.0 (2023/10/16)
|
||||
%% csvsimple-doc.sty: style file for the documentation
|
||||
%%
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%% Copyright (c) 2008-2023 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%%
|
||||
%% This work may be distributed and/or modified under the
|
||||
%% conditions of the LaTeX Project Public License, either version 1.3
|
||||
%% of this license or (at your option) any later version.
|
||||
%% The latest version of this license is in
|
||||
%% http://www.latex-project.org/lppl.txt
|
||||
%% and version 1.3 or later is part of all distributions of LaTeX
|
||||
%% version 2005/12/01 or later.
|
||||
%%
|
||||
%% This work has the LPPL maintenance status `author-maintained'.
|
||||
%%
|
||||
%% This work consists of all files listed in README.md
|
||||
%%
|
||||
\def\version{2.5.0}%
|
||||
\def\datum{2023/10/16}%
|
||||
|
||||
\IfFileExists{csvsimple-doc.cfg}{\input{csvsimple-doc.cfg}}{}\providecommand\csvpkgprefix{}
|
||||
|
||||
% prevent hypdoc from loading (sets hyperindex=false)
|
||||
\@namedef{ver@hypdoc.sty}{9999/12/31}
|
||||
\@namedef{opt@hypdoc.sty}{hypdoc}
|
||||
|
||||
|
||||
\RequirePackage[T1]{fontenc}
|
||||
\RequirePackage[utf8]{inputenc}
|
||||
\RequirePackage[english]{babel}
|
||||
\RequirePackage{lmodern,parskip,array,ifthen,calc,makeidx}
|
||||
\RequirePackage{amsmath,amssymb}
|
||||
\RequirePackage[svgnames,table,hyperref]{xcolor}
|
||||
\RequirePackage{tikz,siunitx,xfp,tabularray}
|
||||
\RequirePackage{varioref}
|
||||
\RequirePackage[pdftex,bookmarks,raiselinks,pageanchor,hyperindex,colorlinks]{hyperref}
|
||||
\urlstyle{sf}
|
||||
\RequirePackage{cleveref}
|
||||
|
||||
\RequirePackage[a4paper,left=2.5cm,right=2.5cm,top=1.5cm,bottom=1.5cm,
|
||||
marginparsep=3mm,marginparwidth=18mm,
|
||||
headheight=0mm,headsep=0cm,
|
||||
footskip=1.5cm,includeheadfoot]{geometry}
|
||||
\RequirePackage{fancyhdr}
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{\thepage}%
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\renewcommand{\footrulewidth}{0pt}
|
||||
\pagestyle{fancy}
|
||||
\tolerance=2000%
|
||||
\setlength{\emergencystretch}{20pt}%
|
||||
|
||||
\RequirePackage{longtable,booktabs,ifthen,etoolbox}
|
||||
|
||||
\RequirePackage{tcolorbox}
|
||||
\tcbuselibrary{skins,xparse,minted,breakable,documentation,raster}
|
||||
|
||||
\definecolor{Green_Dark}{rgb}{0.078431,0.407843,0.176471}
|
||||
\definecolor{Blue_Dark}{rgb}{0.090196,0.211765,0.364706}
|
||||
\definecolor{Blue_Bright}{rgb}{0.858824,0.898039,0.945098}
|
||||
|
||||
\tcbset{skin=enhanced,
|
||||
minted options={fontsize=\footnotesize},
|
||||
doc head={colback=yellow!10!white,interior style=fill},
|
||||
doc head key={colback=magenta!5!white,interior style=fill},
|
||||
color key=DarkViolet,
|
||||
color value=Teal,
|
||||
color color=Teal,
|
||||
color counter=Orange!85!black,
|
||||
color length=Orange!85!black,
|
||||
index colorize,
|
||||
index annotate,
|
||||
beforeafter example/.style={
|
||||
before skip=4pt plus 2pt minus 1pt,
|
||||
after skip=8pt plus 4pt minus 2pt
|
||||
},
|
||||
docexample/.style={bicolor,
|
||||
beforeafter example,
|
||||
arc is angular,fonttitle=\bfseries,
|
||||
fontlower=\footnotesize,
|
||||
colframe=green!25!yellow!50!black,
|
||||
colback=green!25!yellow!7,
|
||||
colbacklower=white,
|
||||
drop fuzzy shadow=green!25!yellow!50!black,
|
||||
listing engine=minted,
|
||||
documentation minted style=colorful,
|
||||
documentation minted options={fontsize=\footnotesize},
|
||||
},
|
||||
}
|
||||
|
||||
\renewcommand*{\tcbdocnew}[1]{\textcolor{green!50!black}{\sffamily\bfseries N} #1}
|
||||
\renewcommand*{\tcbdocupdated}[1]{\textcolor{blue!75!black}{\sffamily\bfseries U} #1}
|
||||
|
||||
\NewDocumentCommand{\csvsorter}{}{\textsf{\bfseries\color{red!20!black}CSV-Sorter}}
|
||||
|
||||
\newtcbinputlisting{\csvlisting}[1]{docexample,minted options={fontsize=\footnotesize},minted language=latex,
|
||||
fonttitle=\bfseries,listing only,title={CSV file \flqq\texttt{\detokenize{#1.csv}}\frqq},listing file=#1.csv}
|
||||
|
||||
\newtcbinputlisting{\xmllisting}[1]{docexample,minted options={fontsize=\footnotesize},minted language=xml,
|
||||
fonttitle=\bfseries,listing only,title={Configuration file \flqq\texttt{\detokenize{#1.xml}}\frqq},listing file=#1.xml}
|
||||
|
||||
\NewTotalTCBox{\verbbox}{m}{enhanced,on line,size=fbox,frame empty,colback=red!5!white,
|
||||
colupper=red!85!black,fontupper=\bfseries\ttfamily}{\detokenize{"}#1\detokenize{"}}
|
||||
|
||||
\NewDocumentCommand{\ctanpkg}{m}
|
||||
{%
|
||||
\href{https://ctan.org/pkg/#1}{\texttt{#1}}%
|
||||
}
|
||||
|
||||
\makeindex
|
||||
|
||||
\pdfsuppresswarningpagegroup=1
|
5
csvsimple/csvsimple-example.csv
Normal file
5
csvsimple/csvsimple-example.csv
Normal file
|
@ -0,0 +1,5 @@
|
|||
last name,first name,address,zip,telephone,year of birth
|
||||
Appleby,Anne,Shrimpsbury,SH-124,555-4455,1960
|
||||
Brown,Carl,Midsomer Garden,MD-945,555-2423,1982
|
||||
Smith,John,Shrimpsbury,SH-123,555-4584,1978
|
||||
Underwood,Mary,Oglsby,OG-345,555-3434,1956
|
|
BIN
csvsimple/csvsimple-example.pdf
Normal file
BIN
csvsimple/csvsimple-example.pdf
Normal file
Binary file not shown.
110
csvsimple/csvsimple-example.tex
Normal file
110
csvsimple/csvsimple-example.tex
Normal file
|
@ -0,0 +1,110 @@
|
|||
%% The LaTeX package csvsimple - version 2.5.0 (2023/10/16)
|
||||
%% csvsimple-example.tex: an example for csvsimple
|
||||
%%
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%% Copyright (c) 2008-2023 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%%
|
||||
%% This work may be distributed and/or modified under the
|
||||
%% conditions of the LaTeX Project Public License, either version 1.3
|
||||
%% of this license or (at your option) any later version.
|
||||
%% The latest version of this license is in
|
||||
%% http://www.latex-project.org/lppl.txt
|
||||
%% and version 1.3 or later is part of all distributions of LaTeX
|
||||
%% version 2005/12/01 or later.
|
||||
%%
|
||||
%% This work has the LPPL maintenance status `author-maintained'.
|
||||
%%
|
||||
%% This work consists of all files listed in README.md
|
||||
%%
|
||||
\documentclass{article}
|
||||
\usepackage{ifthen,array,booktabs}
|
||||
|
||||
\IfFileExists{csvsimple-doc.cfg}{\input{csvsimple-doc.cfg}}{}% ignore this line
|
||||
\providecommand\csvpkgprefix{} % ignore this line
|
||||
|
||||
\usepackage{\csvpkgprefix csvsimple-l3}% \usepackage{csvsimple-l3}
|
||||
|
||||
\begin{document}
|
||||
|
||||
%----------------------------------------------------------
|
||||
\section{Automatic table generation (for testing)}
|
||||
|
||||
{\small
|
||||
\csvautotabular{csvsimple-example.csv}}
|
||||
|
||||
|
||||
%----------------------------------------------------------
|
||||
\section{My first CSV table}
|
||||
\csvreader[tabular=|l|l|,
|
||||
table head=\hline\multicolumn{2}{|c|}{\bfseries My telephone book}\\\hline
|
||||
\bfseries Name & \bfseries Number\\\hline\hline,
|
||||
late after line=\\\hline]%
|
||||
{csvsimple-example.csv}{last name=\surname,first name=\givenname,telephone=\telephone}{%
|
||||
\givenname\ \surname & \telephone
|
||||
}
|
||||
|
||||
|
||||
%----------------------------------------------------------
|
||||
\section{Remembering the names}
|
||||
\csvnames{my names}{last name=\surname,first name=\givenname,address=\address,zip=\zip,telephone=\telephone,year of birth=\birthyear}
|
||||
|
||||
\csvreader[my names, late after line=\\, late after last line=]%
|
||||
{csvsimple-example.csv}{}{%
|
||||
\givenname\ was born in \birthyear\ and lives in \address.
|
||||
}
|
||||
|
||||
|
||||
%----------------------------------------------------------
|
||||
\section{Filter fun}
|
||||
|
||||
\csvreader[my names, filter equal={\address}{Shrimpsbury}, tabbing,
|
||||
table head=\bfseries Shrimpsbury friends: \=\hspace*{3cm}\=\+\kill,
|
||||
before first line=\<\bfseries Shrimpsbury friends:\>]%
|
||||
{csvsimple-example.csv}{}{%
|
||||
\surname, \givenname \> \telephone
|
||||
}
|
||||
|
||||
|
||||
%----------------------------------------------------------
|
||||
\section{More filter fun}
|
||||
|
||||
\csvreader[my names, filter ifthen=\birthyear<1980, centered tabular=rllr,
|
||||
table head=\multicolumn{4}{c}{\bfseries People born before 1980}\\\toprule
|
||||
\# & Name & Postal address & input line no.\\\midrule,
|
||||
late after line=\\, late after last line=\\\bottomrule]%
|
||||
{csvsimple-example.csv}{}{%
|
||||
\thecsvrow & \givenname\ \surname & \zip\ \address & \thecsvinputline
|
||||
}
|
||||
|
||||
|
||||
%----------------------------------------------------------
|
||||
\section{Again and again}
|
||||
|
||||
\csvstyle{my table}{my names,
|
||||
centered tabular=|r|l|l|l|,
|
||||
table head=\hline\multicolumn{4}{|c|}{\bfseries #1}\\\hline
|
||||
\# & Name & Telephone & Postal address\\\hline\hline,
|
||||
late after line=\\, late after last line=\\\hline}
|
||||
|
||||
\csvreader[my table=Predefined table]{csvsimple-example.csv}{}{%
|
||||
\thecsvrow & \givenname\ \surname & \telephone & \zip\ \address
|
||||
}
|
||||
|
||||
\csvreader[my table=Filtering for Smith, filter equal={\surname}{Smith}]%
|
||||
{csvsimple-example.csv}{}{%
|
||||
\thecsvrow & \givenname\ \surname & \telephone & \zip\ \address
|
||||
}
|
||||
|
||||
\csvstyle{all and everything}{my table=#1, file={csvsimple-example.csv},
|
||||
command=\thecsvrow & \givenname\ \surname & \telephone & \zip\ \address}
|
||||
|
||||
\csvloop{all and everything=Loop instead of reader}
|
||||
|
||||
\csvloop{all and everything=With Shrimpsbury filter, filter equal={\address}{Shrimpsbury}}
|
||||
|
||||
\csvloop{all and everything=A little modification, late after line=\\\hline}
|
||||
|
||||
|
||||
\end{document}
|
||||
|
BIN
csvsimple/csvsimple-l3.pdf
Normal file
BIN
csvsimple/csvsimple-l3.pdf
Normal file
Binary file not shown.
1605
csvsimple/csvsimple-l3.sty
Normal file
1605
csvsimple/csvsimple-l3.sty
Normal file
File diff suppressed because it is too large
Load diff
3119
csvsimple/csvsimple-l3.tex
Normal file
3119
csvsimple/csvsimple-l3.tex
Normal file
File diff suppressed because it is too large
Load diff
BIN
csvsimple/csvsimple-legacy.pdf
Normal file
BIN
csvsimple/csvsimple-legacy.pdf
Normal file
Binary file not shown.
795
csvsimple/csvsimple-legacy.sty
Normal file
795
csvsimple/csvsimple-legacy.sty
Normal file
|
@ -0,0 +1,795 @@
|
|||
%% The LaTeX package csvsimple - version 2.5.0 (2023/10/16)
|
||||
%% csvsimple-legacy.sty: Simple LaTeX CSV file processing (LaTeX2e)
|
||||
%%
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%% Copyright (c) 2008-2023 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%%
|
||||
%% This work may be distributed and/or modified under the
|
||||
%% conditions of the LaTeX Project Public License, either version 1.3
|
||||
%% of this license or (at your option) any later version.
|
||||
%% The latest version of this license is in
|
||||
%% http://www.latex-project.org/lppl.txt
|
||||
%% and version 1.3 or later is part of all distributions of LaTeX
|
||||
%% version 2005/12/01 or later.
|
||||
%%
|
||||
%% This work has the LPPL maintenance status `author-maintained'.
|
||||
%%
|
||||
%% This work consists of all files listed in README.md
|
||||
%%
|
||||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesPackage{csvsimple-legacy}[2023/10/16 version 2.5.0 LaTeX2e CSV file processing]
|
||||
|
||||
|
||||
%---- check package
|
||||
\ExplSyntaxOn
|
||||
\cs_if_exist:NT \c__csvsim_package_expl_bool
|
||||
{
|
||||
\msg_new:nnn { csvsimple }{ legacy / package-loaded }
|
||||
{ Package~'csvsimple-l3'~seems~already~be~loaded!~
|
||||
'csvsimple-legacy'~cannot~be~loaded~simultaneously.~
|
||||
Therefore,~loading~of~'csvsimple-legacy'~stops~now.}
|
||||
\msg_warning:nn { csvsimple }{ legacy / package-loaded }
|
||||
\tex_endinput:D
|
||||
}
|
||||
\bool_const:Nn \c__csvsim_package_expl_bool { \c_false_bool }
|
||||
\ExplSyntaxOff
|
||||
|
||||
|
||||
|
||||
\RequirePackage{pgfrcs,pgfkeys,ifthen,etoolbox,shellesc}
|
||||
|
||||
|
||||
%---- general
|
||||
|
||||
\def\csv@warning#1{\PackageWarning{csvsimple}{#1}}
|
||||
\def\csv@error#1#2{\PackageError{csvsimple}{#1}{#2}}
|
||||
|
||||
\newread\csv@file
|
||||
\newcounter{csvinputline}
|
||||
\newcounter{csvrow}
|
||||
\newcounter{csvcol}
|
||||
|
||||
\def\csv@empty{}
|
||||
|
||||
\long\def\csviffirstrow#1#2{%
|
||||
\ifnum\c@csvrow=1%
|
||||
\long\def\csviffirstrow@doit{#1}%
|
||||
\else%
|
||||
\long\def\csviffirstrow@doit{#2}%
|
||||
\fi%
|
||||
\csviffirstrow@doit%
|
||||
}
|
||||
|
||||
\long\def\csvifoddrow#1#2{%
|
||||
\ifodd\c@csvrow%
|
||||
\long\def\csvifoddrow@doit{#1}%
|
||||
\else%
|
||||
\long\def\csvifoddrow@doit{#2}%
|
||||
\fi%
|
||||
\csvifoddrow@doit%
|
||||
}
|
||||
|
||||
\def\csv@assemble@csvlinetotablerow{%
|
||||
\global\c@csvcol 1\relax%
|
||||
\xdef\csvlinetotablerow{\expandonce{\csname csvcol\romannumeral\c@csvcol\endcsname}}%
|
||||
\ifnum\c@csvcol<\csv@columncount\relax%
|
||||
\loop%
|
||||
\global\advance\c@csvcol 1\relax%
|
||||
\xappto\csvlinetotablerow{\noexpand&\expandonce{\csname csvcol\romannumeral\c@csvcol\endcsname}}%
|
||||
\ifnum\c@csvcol<\csv@columncount\relax\repeat%
|
||||
\fi%
|
||||
\csvlinetotablerow%
|
||||
}
|
||||
|
||||
|
||||
%---- breaking lines
|
||||
|
||||
% This command removes leading and trailing spaces from <Token>. I found
|
||||
% the original code on the web. The original author was Michael Downes, who
|
||||
% provided the code as an answer to 'around the bend' question #15.
|
||||
\catcode`\Q=3
|
||||
\def\csv@TrimSpaces#1{%
|
||||
\begingroup%
|
||||
\aftergroup\toks\aftergroup0\aftergroup{%
|
||||
\expandafter\csv@trimb\expandafter\noexpand#1Q Q}%
|
||||
\global\edef#1{\the\toks0}%
|
||||
}
|
||||
\def\csv@trimb#1 Q{\csv@trimc#1Q}
|
||||
\def\csv@trimc#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1}
|
||||
\catcode`\Q=11
|
||||
|
||||
\def\csv@TrimBraces#1{\expandafter\csv@TrimBraces@#1\@nil{#1}}
|
||||
\def\csv@TrimBraces@#1\@nil#2{\def#2{#1}}
|
||||
|
||||
\def\csv@breakline@kernel#1{%
|
||||
\ifx\csv@termination#1\let\nextcol=\relax\else%
|
||||
\let\nextcol=\csv@breakline%
|
||||
\global\advance\c@csvcol 1\relax%
|
||||
\def\csv@col@body{#1}%
|
||||
\csv@TrimSpaces\csv@col@body%
|
||||
\csv@TrimBraces\csv@col@body%
|
||||
\toks@\expandafter{\csv@col@body}%
|
||||
\expandafter\xdef\csname csvcol\romannumeral\c@csvcol\endcsname{\the\toks@}%
|
||||
\fi%
|
||||
\nextcol%
|
||||
}
|
||||
|
||||
% comma
|
||||
\def\csv@breakline@A#1,{\csv@breakline@kernel{#1}}
|
||||
|
||||
\def\csv@scanline@A#1{%
|
||||
\global\c@csvcol 0\relax%
|
||||
\csv@breakline#1,\csv@termination,%
|
||||
}
|
||||
|
||||
% semi colon
|
||||
\def\csv@breakline@B#1;{\csv@breakline@kernel{#1}}
|
||||
|
||||
\def\csv@scanline@B#1{%
|
||||
\global\c@csvcol 0\relax%
|
||||
\csv@breakline#1;\csv@termination;%
|
||||
}
|
||||
|
||||
% pipe
|
||||
\def\csv@breakline@C#1|{\csv@breakline@kernel{#1}}
|
||||
|
||||
\def\csv@scanline@C#1{%
|
||||
\global\c@csvcol 0\relax%
|
||||
\csv@breakline#1|\csv@termination|%
|
||||
}
|
||||
|
||||
% tab
|
||||
\catcode`\^^I=12
|
||||
\def\csv@breakline@D#1^^I{\csv@breakline@kernel{#1}}
|
||||
|
||||
\def\csv@scanline@D#1{%
|
||||
\global\c@csvcol 0\relax%
|
||||
\csv@breakline#1^^I\csv@termination^^I%
|
||||
}
|
||||
\catcode`\^^I=10
|
||||
|
||||
% expands a CSV line and scans content
|
||||
\def\csv@escanline#1{%
|
||||
\toks@\expandafter{#1}%
|
||||
\edef\@csv@scanline{\noexpand\csv@scanline{\the\toks@}}%
|
||||
\@csv@scanline%
|
||||
}
|
||||
|
||||
{
|
||||
\catcode`\"=12%
|
||||
\gdef\csv@passivquotes{"}
|
||||
}
|
||||
|
||||
\newwrite\csv@out
|
||||
|
||||
\def\csv@preprocessor@csvsorter#1#2#3{%
|
||||
\begingroup%
|
||||
\typeout{<sort \csv@passivquotes#2\csv@passivquotes\space by \csv@passivquotes#1\csv@passivquotes>}%
|
||||
\immediate\openout\csv@out=\csv@csvsorter@token%
|
||||
\immediate\write\csv@out{\string\makeatletter\string\csv@error{Call of CSV-Sorter failed! Use '-shell-escape' option or check log file '\csv@csvsorter@log'.}{}}%
|
||||
\immediate\closeout\csv@out%
|
||||
\ShellEscape{\csv@csvsorter@command\space
|
||||
-c \csv@passivquotes#1\csv@passivquotes\space
|
||||
-l \csv@passivquotes\csv@csvsorter@log\csv@passivquotes\space
|
||||
-t \csv@passivquotes\csv@csvsorter@token\csv@passivquotes\space
|
||||
-i \csv@passivquotes#2\csv@passivquotes\space
|
||||
-o \csv@passivquotes#3\csv@passivquotes\space -q 1}%
|
||||
\input{\csv@csvsorter@token}%
|
||||
\endgroup%
|
||||
}
|
||||
|
||||
|
||||
\def\csv@preprocss@none{%
|
||||
\let\csv@input@filename=\csv@filename%
|
||||
}
|
||||
|
||||
\def\csv@preprocss@procedure{%
|
||||
\csv@preprocessor{\csv@filename}{\csv@ppfilename}%
|
||||
\let\csv@input@filename=\csv@ppfilename%
|
||||
}
|
||||
|
||||
|
||||
%---- the loop
|
||||
|
||||
\def\csv@AtEndLoop{\gappto\@endloophook}
|
||||
\let\@endloophook\csv@empty
|
||||
|
||||
\def\csv@current@col{\csname csvcol\romannumeral\c@csvcol\endcsname}
|
||||
|
||||
% auto head names
|
||||
\def\set@csv@autohead{%
|
||||
\toks0=\expandafter{\csname\csv@headnameprefix\csv@current@col\endcsname}%
|
||||
\toks1=\expandafter{\csname csvcol\romannumeral\c@csvcol\endcsname}%
|
||||
\begingroup\edef\csv@temp{\endgroup\noexpand\gdef\the\toks0{\the\toks1}\noexpand\csv@AtEndLoop{\noexpand\gdef\the\toks0{}}}%
|
||||
\csv@temp%
|
||||
}
|
||||
|
||||
% head names and numbers
|
||||
\def\set@csv@head{%
|
||||
\toks0={\gdef##1}%
|
||||
\toks1=\expandafter{\csname csvcol\romannumeral\c@csvcol\endcsname}%
|
||||
\begingroup\edef\csv@temp{\endgroup\noexpand\pgfkeysdef{/csv head/\csv@current@col}{\the\toks0{\the\toks1}\noexpand\csv@AtEndLoop{\the\toks0{}}}}%
|
||||
\csv@temp%
|
||||
\begingroup\edef\csv@temp{\endgroup\noexpand\pgfkeysdef{/csv head/\thecsvcol}{\the\toks0{\the\toks1}\noexpand\csv@AtEndLoop{\the\toks0{}}}}%
|
||||
\csv@temp%
|
||||
}
|
||||
|
||||
% head line
|
||||
\def\csv@processheadline{%
|
||||
\csvreadnext%
|
||||
\ifx\csv@par\csvline\relax%
|
||||
\csv@error{File '\csv@input@filename' starts with an empty line!}{}%
|
||||
\else\csv@escanline{\csvline}%
|
||||
\fi%
|
||||
\xdef\csv@columncount{\thecsvcol}%
|
||||
\global\c@csvcol 0\relax%
|
||||
\loop%
|
||||
\global\advance\c@csvcol 1\relax%
|
||||
\csv@opt@headtocolumnames%
|
||||
\set@csv@head%
|
||||
\ifnum\c@csvcol<\csv@columncount\repeat%
|
||||
\toks@=\expandafter{\csv@columnnames}%
|
||||
\edef\csv@processkeys{\noexpand\pgfkeys{/csv head/.cd,\the\toks@}}%
|
||||
\csv@processkeys%
|
||||
\csv@posthead%
|
||||
}
|
||||
|
||||
% head numbers for no head
|
||||
\def\set@csv@nohead{%
|
||||
\toks0={\gdef##1}%
|
||||
\toks1=\expandafter{\csname csvcol\romannumeral\c@csvcol\endcsname}%
|
||||
\begingroup\edef\csv@temp{\endgroup\noexpand\pgfkeysdef{/csv head/\thecsvcol}{\the\toks0{\the\toks1}\noexpand\csv@AtEndLoop{\the\toks0{}}}}%
|
||||
\csv@temp%
|
||||
}
|
||||
|
||||
% no head line
|
||||
\def\csv@noheadline{%
|
||||
\global\c@csvcol 0\relax%
|
||||
\loop%
|
||||
\global\advance\c@csvcol 1\relax%
|
||||
\set@csv@nohead%
|
||||
\ifnum\c@csvcol<\csv@columncount\repeat%
|
||||
\toks@=\expandafter{\csv@columnnames}%
|
||||
\edef\csv@processkeys{\noexpand\pgfkeys{/csv head/.cd,\the\toks@}}%
|
||||
\csv@processkeys%
|
||||
}
|
||||
|
||||
% check filter
|
||||
\def\csv@checkfilter{%
|
||||
\csv@prefiltercommand%
|
||||
\csv@iffilter{%
|
||||
\stepcounter{csvrow}%
|
||||
\let\csv@usage=\csv@do@linecommand%
|
||||
}{}%
|
||||
}
|
||||
|
||||
\def\csv@truefilter#1#2{#1}
|
||||
|
||||
\def\csv@falsefilter#1#2{#2}
|
||||
|
||||
\def\csvfilteraccept{\global\let\csv@iffilter=\csv@truefilter}
|
||||
|
||||
\def\csvfilterreject{\global\let\csv@iffilter=\csv@falsefilter}
|
||||
|
||||
% check columns
|
||||
\def\csv@checkcolumncount{%
|
||||
\ifnum\c@csvcol=\csv@columncount\relax%
|
||||
\csv@checkfilter%
|
||||
\else%
|
||||
\csv@columncounterror%
|
||||
\fi%
|
||||
}
|
||||
|
||||
\def\csv@nocheckcolumncount{%
|
||||
\csv@checkfilter%
|
||||
}
|
||||
|
||||
% normal line
|
||||
\def\csv@do@linecommand{%
|
||||
\csv@do@latepostline%
|
||||
\csv@do@preline%
|
||||
\csv@body\relax%
|
||||
\csv@do@postline%
|
||||
}
|
||||
|
||||
\gdef\csvreadnext{%
|
||||
\global\read\csv@file to\csvline%
|
||||
\stepcounter{csvinputline}%
|
||||
}
|
||||
|
||||
\def\csv@par{\par}
|
||||
|
||||
% reads and processes a CSV file
|
||||
\long\def\csvloop#1{%
|
||||
% reset
|
||||
\global\let\@endloophook\csv@empty%
|
||||
\global\let\csvlinetotablerow\csv@assemble@csvlinetotablerow%
|
||||
% options
|
||||
\csvset{default,every csv,#1}%
|
||||
\csv@preprocss%
|
||||
\csv@set@catcodes%
|
||||
\csv@prereading%
|
||||
\csv@table@begin%
|
||||
\setcounter{csvinputline}{0}%
|
||||
% start reading
|
||||
\openin\csv@file=\csv@input@filename\relax%
|
||||
\ifeof\csv@file%
|
||||
\csv@error{File '\csv@input@filename' not existent, not readable, or empty!}{}%
|
||||
\else%
|
||||
% the head line
|
||||
\csv@opt@processheadline%
|
||||
\fi%
|
||||
%
|
||||
\setcounter{csvrow}{0}%
|
||||
\gdef\csv@do@preline{%
|
||||
\csv@prefirstline%
|
||||
\global\let\csv@do@preline=\csv@preline%
|
||||
}%
|
||||
\gdef\csv@do@postline{%
|
||||
\csv@postfirstline%
|
||||
\global\let\csv@do@postline=\csv@postline%
|
||||
}%
|
||||
\gdef\csv@do@@latepostline{%
|
||||
\csv@latepostfirstline%
|
||||
\global\let\csv@do@latepostline=\csv@latepostline%
|
||||
}%
|
||||
\gdef\csv@do@latepostline{%
|
||||
\csv@lateposthead%
|
||||
\global\let\csv@do@latepostline=\csv@do@@latepostline%
|
||||
}%
|
||||
% command for the reading loop
|
||||
\gdef\csv@iterate{%
|
||||
\let\csv@usage=\csv@empty%
|
||||
\csvreadnext%
|
||||
\ifeof\csv@file%
|
||||
\global\let\csv@next=\csv@empty%
|
||||
\else%
|
||||
\global\let\csv@next=\csv@iterate%
|
||||
\ifx\csv@par\csvline\relax%
|
||||
\else%
|
||||
\csv@escanline{\csvline}%
|
||||
% check and decide
|
||||
\csv@opt@checkcolumncount%
|
||||
\fi%
|
||||
\fi%
|
||||
% do or do not
|
||||
\csv@usage%
|
||||
\csv@next}%
|
||||
\ifeof\csv@file%
|
||||
\global\let\csv@next=\csv@empty%
|
||||
\else%
|
||||
\global\let\csv@next=\csv@iterate%
|
||||
\fi%
|
||||
\csv@next%
|
||||
\closein\csv@file%
|
||||
\@endloophook%
|
||||
\csv@latepostlastline%
|
||||
\csv@table@end%
|
||||
\csv@postreading%
|
||||
\csv@reset@catcodes%
|
||||
}
|
||||
|
||||
% user command
|
||||
\long\def\csv@reader[#1]#2#3#4{%
|
||||
\global\long\def\csv@@body{#4}%
|
||||
\csvloop{#1,file={#2},column names={#3},command=\csv@@body}%
|
||||
}
|
||||
|
||||
\def\csvreader{%
|
||||
\@ifnextchar[{\csv@reader}{\csv@reader[]}}
|
||||
|
||||
|
||||
%---- keys
|
||||
|
||||
\pgfkeys{/handlers/.gstore in/.code=\pgfkeysalso{\pgfkeyscurrentpath/.code=\gdef#1{##1}}}
|
||||
\pgfkeys{/csv/.is family}
|
||||
\pgfkeys{/csv head/.is family}
|
||||
|
||||
\def\csvset{\pgfqkeys{/csv}}
|
||||
\def\csvheadset{\pgfqkeys{/csv head}}
|
||||
|
||||
\csvset{%
|
||||
file/.gstore in=\csv@filename,%
|
||||
preprocessed file/.gstore in=\csv@ppfilename,%
|
||||
preprocessor/.code={\gdef\csv@preprocessor{#1}\let\csv@preprocss=\csv@preprocss@procedure},%
|
||||
no preprocessing/.code={\let\csv@preprocss=\csv@preprocss@none},
|
||||
column names reset/.code={\gdef\csv@columnnames{}},%
|
||||
column names/.code={%
|
||||
\toks0=\expandafter{\csv@columnnames}%
|
||||
\def\temp{#1}\toks1=\expandafter{\temp}%
|
||||
\xdef\csv@columnnames{\the\toks0,\the\toks1}%
|
||||
},
|
||||
command/.gstore in=\csv@body,%
|
||||
check column count/.is choice,%
|
||||
check column count/.default=true,%
|
||||
check column count/true/.code={\global\let\csv@opt@checkcolumncount=\csv@checkcolumncount},%
|
||||
check column count/false/.code={\global\let\csv@opt@checkcolumncount=\csv@nocheckcolumncount},%
|
||||
on column count error/.gstore in=\csv@columncounterror,
|
||||
head/.is choice,%
|
||||
head/.default=true,%
|
||||
head/true/.code={\global\let\csv@opt@processheadline=\csv@processheadline%
|
||||
\pgfkeysalso{check column count}},%
|
||||
head/false/.code={\global\let\csv@opt@processheadline=\csv@noheadline%
|
||||
\pgfkeysalso{check column count=false,late after head=}},%
|
||||
head to column names prefix/.store in=\csv@headnameprefix,%
|
||||
head to column names/.is choice,%
|
||||
head to column names/.default=true,%
|
||||
head to column names/true/.code={\global\let\csv@opt@headtocolumnames=\set@csv@autohead},%
|
||||
head to column names/false/.code={\global\let\csv@opt@headtocolumnames=\csv@empty},%
|
||||
column count/.gstore in=\csv@columncount,%
|
||||
filter/.code={\gdef\csv@iffilter{\ifthenelse{#1}}},
|
||||
filter ifthen/.code={\gdef\csv@iffilter{\ifthenelse{#1}}},
|
||||
filter test/.code={\gdef\csv@iffilter{#1}},
|
||||
filter expr/.code={\gdef\csv@iffilter{\ifboolexpr{#1}}},
|
||||
no filter/.code={\csvfilteraccept},
|
||||
filter reject all/.code={\csvfilterreject},
|
||||
filter accept all/.code={\csvfilteraccept},
|
||||
before filter/.gstore in=\csv@prefiltercommand,
|
||||
full filter/.gstore in=\csv@prefiltercommand,
|
||||
before first line/.gstore in=\csv@prefirstline,
|
||||
before line/.code={\gdef\csv@preline{#1}\pgfkeysalso{before first line=#1}},
|
||||
after first line/.gstore in=\csv@postfirstline,
|
||||
after line/.code={\gdef\csv@postline{#1}\pgfkeysalso{after first line=#1}},
|
||||
late after first line/.gstore in=\csv@latepostfirstline,
|
||||
late after last line/.gstore in=\csv@latepostlastline,
|
||||
late after line/.code={\gdef\csv@latepostline{#1}\pgfkeysalso{late after first line=#1,late after last line=#1}},
|
||||
after head/.gstore in=\csv@posthead,
|
||||
late after head/.gstore in=\csv@lateposthead,
|
||||
before reading/.gstore in=\csv@prereading,
|
||||
after reading/.gstore in=\csv@postreading,
|
||||
before table/.gstore in=\csv@pretable,
|
||||
after table/.gstore in=\csv@posttable,
|
||||
table head/.gstore in=\csv@tablehead,
|
||||
table foot/.gstore in=\csv@tablefoot,
|
||||
@table/.code 2 args={\gdef\csv@table@begin{#1}\gdef\csv@table@end{#2}},
|
||||
no table/.style={@table={}{}},
|
||||
separator/.is choice,
|
||||
separator/comma/.code={\global\let\csv@scanline=\csv@scanline@A%
|
||||
\global\let\csv@breakline\csv@breakline@A},
|
||||
separator/semicolon/.code={\global\let\csv@scanline=\csv@scanline@B%
|
||||
\global\let\csv@breakline\csv@breakline@B},
|
||||
separator/pipe/.code={\global\let\csv@scanline=\csv@scanline@C%
|
||||
\global\let\csv@breakline\csv@breakline@C},
|
||||
separator/tab/.code={\global\let\csv@scanline=\csv@scanline@D%
|
||||
\global\let\csv@breakline\csv@breakline@D%
|
||||
\csvset{respect tab}},
|
||||
%
|
||||
csvsorter command/.store in=\csv@csvsorter@command,
|
||||
csvsorter configpath/.store in=\csv@csvsorter@configpath,
|
||||
sort by/.style={preprocessor={\csv@preprocessor@csvsorter{\csv@csvsorter@configpath/#1}}},
|
||||
new sorting rule/.style 2 args={sort by #1/.style={sort by={#2}}},
|
||||
csvsorter log/.store in=\csv@csvsorter@log,
|
||||
csvsorter token/.store in=\csv@csvsorter@token,
|
||||
csvsorter command=csvsorter,
|
||||
csvsorter configpath=.,
|
||||
preprocessed file={\jobname_sorted._csv},
|
||||
csvsorter log={csvsorter.log},
|
||||
csvsorter token={\jobname.csvtoken},
|
||||
%
|
||||
% default for reset
|
||||
default/.style={
|
||||
file=unknown.csv,
|
||||
no preprocessing,
|
||||
command=\csvline,
|
||||
column names reset,
|
||||
head,
|
||||
head to column names prefix=,
|
||||
head to column names=false,
|
||||
column count=10,
|
||||
on column count error=,
|
||||
no filter,
|
||||
before filter=,
|
||||
before line=,
|
||||
after line=,
|
||||
late after line=,
|
||||
after head=,
|
||||
late after head=,
|
||||
before reading=,
|
||||
after reading=,
|
||||
before table=,
|
||||
after table=,
|
||||
table head=,
|
||||
table foot=,
|
||||
no table,
|
||||
separator=comma,
|
||||
},
|
||||
default,
|
||||
%
|
||||
% styles
|
||||
every csv/.style={},
|
||||
no head/.style={head=false},
|
||||
no check column count/.style={check column count=false},
|
||||
warn on column count error/.style={on column count error={\csv@warning{>\thecsvcol< instead of >\csv@columncount< columns for input line >\thecsvinputline< of file >\csv@ppfilename<}}},
|
||||
filter equal/.style 2 args={filter ifthen=\equal{#1}{#2}},
|
||||
filter not equal/.style 2 args={filter ifthen=\not\equal{#1}{#2}},
|
||||
filter strcmp/.style 2 args={filter test=\ifcsvstrcmp{#1}{#2}},
|
||||
filter not strcmp/.style 2 args={filter test=\ifcsvnotstrcmp{#1}{#2}},
|
||||
tabular/.style={
|
||||
@table={\csv@pretable\begin{tabular}{#1}\csv@tablehead}{\csv@tablefoot\end{tabular}\csv@posttable},
|
||||
late after line=\\},
|
||||
centered tabular/.style={
|
||||
@table={\begin{center}\csv@pretable\begin{tabular}{#1}\csv@tablehead}{\csv@tablefoot\end{tabular}\csv@posttable\end{center}},
|
||||
late after line=\\},
|
||||
longtable/.style={
|
||||
@table={\csv@pretable\begin{longtable}{#1}\csv@tablehead}{\csv@tablefoot\end{longtable}\csv@posttable},
|
||||
late after line=\\},
|
||||
tabbing/.style={
|
||||
@table={\csv@pretable\begin{tabbing}\csv@tablehead}{\csv@tablefoot\end{tabbing}\csv@posttable},
|
||||
late after line=\\,
|
||||
late after last line=},
|
||||
centered tabbing/.style={
|
||||
@table={\begin{center}\csv@pretable\begin{tabbing}\csv@tablehead}{\csv@tablefoot\end{tabbing}\csv@posttable\end{center}},
|
||||
late after line=\\,
|
||||
late after last line=},
|
||||
autotabular/.style={
|
||||
file=#1,
|
||||
after head=\csv@pretable\begin{tabular}{|*{\csv@columncount}{l|}}\csv@tablehead,
|
||||
table head=\hline\csvlinetotablerow\\\hline,
|
||||
late after line=\\,
|
||||
table foot=\\\hline,
|
||||
late after last line=\csv@tablefoot\end{tabular}\csv@posttable,
|
||||
command=\csvlinetotablerow},
|
||||
autolongtable/.style={
|
||||
file=#1,
|
||||
after head=\csv@pretable\begin{longtable}{|*{\csv@columncount}{l|}}\csv@tablehead,
|
||||
table head=\hline\csvlinetotablerow\\\hline\endhead\hline\endfoot,
|
||||
late after line=\\,
|
||||
late after last line=\csv@tablefoot\end{longtable}\csv@posttable,
|
||||
command=\csvlinetotablerow},
|
||||
autobooktabular/.style={
|
||||
file=#1,
|
||||
after head=\csv@pretable\begin{tabular}{*{\csv@columncount}{l}}\csv@tablehead,
|
||||
table head=\toprule\csvlinetotablerow\\\midrule,
|
||||
late after line=\\,
|
||||
table foot=\\\bottomrule,
|
||||
late after last line=\csv@tablefoot\end{tabular}\csv@posttable,
|
||||
command=\csvlinetotablerow},
|
||||
autobooklongtable/.style={
|
||||
file=#1,
|
||||
after head=\csv@pretable\begin{longtable}{*{\csv@columncount}{l}}\csv@tablehead,
|
||||
table head=\toprule\csvlinetotablerow\\\midrule\endhead\bottomrule\endfoot,
|
||||
late after line=\\,
|
||||
late after last line=\csv@tablefoot\end{longtable}\csv@posttable,
|
||||
command=\csvlinetotablerow},
|
||||
}
|
||||
|
||||
% deprecated keys
|
||||
\csvset{
|
||||
nofilter/.style=no filter,
|
||||
nohead/.style=no head,
|
||||
}
|
||||
|
||||
% catcodes
|
||||
\def\csv@set@catcodes{%
|
||||
\csv@catcode@tab@set%
|
||||
\csv@catcode@tilde@set%
|
||||
\csv@catcode@circumflex@set%
|
||||
\csv@catcode@underscore@set%
|
||||
\csv@catcode@and@set%
|
||||
\csv@catcode@sharp@set%
|
||||
\csv@catcode@dollar@set%
|
||||
\csv@catcode@backslash@set%
|
||||
\csv@catcode@leftbrace@set%
|
||||
\csv@catcode@rightbrace@set%
|
||||
\csv@catcode@percent@set}
|
||||
|
||||
\def\csv@reset@catcodes{\csv@catcode@percent@reset%
|
||||
\csv@catcode@rightbrace@reset%
|
||||
\csv@catcode@leftbrace@reset%
|
||||
\csv@catcode@backslash@reset%
|
||||
\csv@catcode@dollar@reset%
|
||||
\csv@catcode@sharp@reset%
|
||||
\csv@catcode@and@reset%
|
||||
\csv@catcode@underscore@reset%
|
||||
\csv@catcode@circumflex@reset%
|
||||
\csv@catcode@tilde@reset%
|
||||
\csv@catcode@tab@reset%
|
||||
}
|
||||
|
||||
|
||||
\csvset{
|
||||
respect tab/.is choice,
|
||||
respect tab/true/.code={%
|
||||
\gdef\csv@catcode@tab@set{%
|
||||
\xdef\csv@catcode@tab@value{\the\catcode`\^^I}%
|
||||
\catcode`\^^I=12}%
|
||||
\gdef\csv@catcode@tab@reset{\catcode`\^^I=\csv@catcode@tab@value}},
|
||||
respect tab/false/.code={%
|
||||
\global\let\csv@catcode@tab@set\csv@empty%
|
||||
\global\let\csv@catcode@tab@reset\csv@empty},
|
||||
respect tab/.default=true,
|
||||
%
|
||||
respect percent/.is choice,
|
||||
respect percent/true/.code={%
|
||||
\gdef\csv@catcode@percent@set{%
|
||||
\xdef\csv@catcode@percent@value{\the\catcode`\%}%
|
||||
\catcode`\%=12}%
|
||||
\gdef\csv@catcode@percent@reset{\catcode`\%=\csv@catcode@percent@value}},
|
||||
respect percent/false/.code={%
|
||||
\global\let\csv@catcode@percent@set\csv@empty%
|
||||
\global\let\csv@catcode@percent@reset\csv@empty},
|
||||
respect percent/.default=true,
|
||||
%
|
||||
respect sharp/.is choice,
|
||||
respect sharp/true/.code={%
|
||||
\gdef\csv@catcode@sharp@set{%
|
||||
\xdef\csv@catcode@sharp@value{\the\catcode`\#}%
|
||||
\catcode`\#=12}%
|
||||
\gdef\csv@catcode@sharp@reset{\catcode`\#=\csv@catcode@sharp@value}},
|
||||
respect sharp/false/.code={%
|
||||
\global\let\csv@catcode@sharp@set\csv@empty%
|
||||
\global\let\csv@catcode@sharp@reset\csv@empty},
|
||||
respect sharp/.default=true,
|
||||
%
|
||||
respect dollar/.is choice,
|
||||
respect dollar/true/.code={%
|
||||
\gdef\csv@catcode@dollar@set{%
|
||||
\xdef\csv@catcode@dollar@value{\the\catcode`\$}%
|
||||
\catcode`\$=12}%
|
||||
\gdef\csv@catcode@dollar@reset{\catcode`\$=\csv@catcode@dollar@value}},
|
||||
respect dollar/false/.code={%
|
||||
\global\let\csv@catcode@dollar@set\csv@empty%
|
||||
\global\let\csv@catcode@dollar@reset\csv@empty},
|
||||
respect dollar/.default=true,
|
||||
%
|
||||
respect and/.is choice,
|
||||
respect and/true/.code={%
|
||||
\gdef\csv@catcode@and@set{%
|
||||
\xdef\csv@catcode@and@value{\the\catcode`\&}%
|
||||
\catcode`\&=12}%
|
||||
\gdef\csv@catcode@and@reset{\catcode`\&=\csv@catcode@and@value}},
|
||||
respect and/false/.code={%
|
||||
\global\let\csv@catcode@and@set\csv@empty%
|
||||
\global\let\csv@catcode@and@reset\csv@empty},
|
||||
respect and/.default=true,
|
||||
%
|
||||
respect backslash/.is choice,
|
||||
respect backslash/true/.code={%
|
||||
\gdef\csv@catcode@backslash@set{%
|
||||
\xdef\csv@catcode@backslash@value{\the\catcode`\\}%
|
||||
\catcode`\\=12}%
|
||||
\gdef\csv@catcode@backslash@reset{\catcode`\\=\csv@catcode@backslash@value}},
|
||||
respect backslash/false/.code={%
|
||||
\global\let\csv@catcode@backslash@set\csv@empty%
|
||||
\global\let\csv@catcode@backslash@reset\csv@empty},
|
||||
respect backslash/.default=true,
|
||||
%
|
||||
respect underscore/.is choice,
|
||||
respect underscore/true/.code={%
|
||||
\gdef\csv@catcode@underscore@set{%
|
||||
\xdef\csv@catcode@underscore@value{\the\catcode`\_}%
|
||||
\catcode`\_=12}%
|
||||
\gdef\csv@catcode@underscore@reset{\catcode`\_=\csv@catcode@underscore@value}},
|
||||
respect underscore/false/.code={%
|
||||
\global\let\csv@catcode@underscore@set\csv@empty%
|
||||
\global\let\csv@catcode@underscore@reset\csv@empty},
|
||||
respect underscore/.default=true,
|
||||
%
|
||||
respect tilde/.is choice,
|
||||
respect tilde/true/.code={%
|
||||
\gdef\csv@catcode@tilde@set{%
|
||||
\xdef\csv@catcode@tilde@value{\the\catcode`\~}%
|
||||
\catcode`\~=12}%
|
||||
\gdef\csv@catcode@tilde@reset{\catcode`\~=\csv@catcode@tilde@value}},
|
||||
respect tilde/false/.code={%
|
||||
\global\let\csv@catcode@tilde@set\csv@empty%
|
||||
\global\let\csv@catcode@tilde@reset\csv@empty},
|
||||
respect tilde/.default=true,
|
||||
%
|
||||
respect circumflex/.is choice,
|
||||
respect circumflex/true/.code={%
|
||||
\gdef\csv@catcode@circumflex@set{%
|
||||
\xdef\csv@catcode@circumflex@value{\the\catcode`\^}%
|
||||
\catcode`\^=12}%
|
||||
\gdef\csv@catcode@circumflex@reset{\catcode`\^=\csv@catcode@circumflex@value}},
|
||||
respect circumflex/false/.code={%
|
||||
\global\let\csv@catcode@circumflex@set\csv@empty%
|
||||
\global\let\csv@catcode@circumflex@reset\csv@empty},
|
||||
respect circumflex/.default=true,
|
||||
%
|
||||
respect leftbrace/.is choice,
|
||||
respect leftbrace/true/.code={%
|
||||
\gdef\csv@catcode@leftbrace@set{%
|
||||
\xdef\csv@catcode@leftbrace@value{\the\catcode`\{}%
|
||||
\catcode`\{=12}%
|
||||
\gdef\csv@catcode@leftbrace@reset{\catcode`\{=\csv@catcode@leftbrace@value}},
|
||||
respect leftbrace/false/.code={%
|
||||
\global\let\csv@catcode@leftbrace@set\csv@empty%
|
||||
\global\let\csv@catcode@leftbrace@reset\csv@empty},
|
||||
respect leftbrace/.default=true,
|
||||
%
|
||||
respect rightbrace/.is choice,
|
||||
respect rightbrace/true/.code={%
|
||||
\gdef\csv@catcode@rightbrace@set{%
|
||||
\xdef\csv@catcode@rightbrace@value{\the\catcode`\}}%
|
||||
\catcode`\}=12}%
|
||||
\gdef\csv@catcode@rightbrace@reset{\catcode`\}=\csv@catcode@rightbrace@value}},
|
||||
respect rightbrace/false/.code={%
|
||||
\global\let\csv@catcode@rightbrace@set\csv@empty%
|
||||
\global\let\csv@catcode@rightbrace@reset\csv@empty},
|
||||
respect rightbrace/.default=true,
|
||||
%
|
||||
respect all/.style={respect tab,respect percent,respect sharp,respect dollar,
|
||||
respect and,respect backslash,respect underscore,respect tilde,respect circumflex,
|
||||
respect leftbrace,respect rightbrace},
|
||||
respect none/.style={respect tab=false,respect percent=false,respect sharp=false,
|
||||
respect dollar=false,respect and=false,respect backslash=false,
|
||||
respect underscore=false,respect tilde=false,respect circumflex=false,
|
||||
respect leftbrace=false,respect rightbrace=false},
|
||||
respect none
|
||||
}
|
||||
|
||||
|
||||
\long\def\csv@autotabular[#1]#2{\csvloop{autotabular={#2},#1}}
|
||||
|
||||
\def\csvautotabular{%
|
||||
\@ifnextchar[{\csv@autotabular}{\csv@autotabular[]}}
|
||||
|
||||
\long\def\csv@autolongtable[#1]#2{\csvloop{autolongtable={#2},#1}}
|
||||
|
||||
\def\csvautolongtable{%
|
||||
\@ifnextchar[{\csv@autolongtable}{\csv@autolongtable[]}}
|
||||
|
||||
\long\def\csv@autobooktabular[#1]#2{\csvloop{autobooktabular={#2},#1}}
|
||||
|
||||
\def\csvautobooktabular{%
|
||||
\@ifnextchar[{\csv@autobooktabular}{\csv@autobooktabular[]}}
|
||||
|
||||
|
||||
\long\def\csv@autobooklongtable[#1]#2{\csvloop{autobooklongtable={#2},#1}}
|
||||
|
||||
\def\csvautobooklongtable{%
|
||||
\@ifnextchar[{\csv@autobooklongtable}{\csv@autobooklongtable[]}}
|
||||
|
||||
|
||||
\def\csvstyle#1#2{\csvset{#1/.style={#2}}}
|
||||
|
||||
\def\csvnames#1#2{\csvset{#1/.style={column names={#2}}}}
|
||||
|
||||
% string comparison
|
||||
|
||||
\newrobustcmd{\ifcsvstrequal}[2]{%
|
||||
\begingroup%
|
||||
\edef\csv@tempa{#1}%
|
||||
\edef\csv@tempb{#2}%
|
||||
\ifx\csv@tempa\csv@tempb%
|
||||
\aftergroup\@firstoftwo%
|
||||
\else%
|
||||
\aftergroup\@secondoftwo%
|
||||
\fi%
|
||||
\endgroup%
|
||||
}%
|
||||
|
||||
\newrobustcmd{\ifcsvprostrequal}[2]{%
|
||||
\begingroup%
|
||||
\protected@edef\csv@tempa{#1}%
|
||||
\protected@edef\csv@tempb{#2}%
|
||||
\ifx\csv@tempa\csv@tempb%
|
||||
\aftergroup\@firstoftwo%
|
||||
\else%
|
||||
\aftergroup\@secondoftwo%
|
||||
\fi%
|
||||
\endgroup%
|
||||
}%
|
||||
|
||||
\AtBeginDocument{%
|
||||
\ifdefined\pdfstrcmp%
|
||||
\let\csv@strcmp\pdfstrcmp%
|
||||
\else\ifdefined\pdf@strcmp%
|
||||
\let\csv@strcmp\pdf@strcmp%
|
||||
\fi\fi%
|
||||
\ifdefined\csv@strcmp%
|
||||
\newrobustcmd{\ifcsvstrcmp}[2]{%
|
||||
\ifnum\csv@strcmp{#1}{#2}=\z@\relax%
|
||||
\expandafter\@firstoftwo%
|
||||
\else%
|
||||
\expandafter\@secondoftwo%
|
||||
\fi%
|
||||
}%
|
||||
\else%
|
||||
\let\ifcsvstrcmp\ifcsvstrequal%
|
||||
\fi%
|
||||
}
|
||||
|
||||
\newrobustcmd{\ifcsvnotstrcmp}[4]{\ifcsvstrcmp{#1}{#2}{#4}{#3}}
|
1970
csvsimple/csvsimple-legacy.tex
Normal file
1970
csvsimple/csvsimple-legacy.tex
Normal file
File diff suppressed because it is too large
Load diff
BIN
csvsimple/csvsimple-title.png
Normal file
BIN
csvsimple/csvsimple-title.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
BIN
csvsimple/csvsimple.pdf
Normal file
BIN
csvsimple/csvsimple.pdf
Normal file
Binary file not shown.
49
csvsimple/csvsimple.sty
Normal file
49
csvsimple/csvsimple.sty
Normal file
|
@ -0,0 +1,49 @@
|
|||
%% The LaTeX package csvsimple - version 2.5.0 (2023/10/16)
|
||||
%% csvsimple.sty: Simple LaTeX CSV file processing
|
||||
%%
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%% Copyright (c) 2008-2023 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%%
|
||||
%% This work may be distributed and/or modified under the
|
||||
%% conditions of the LaTeX Project Public License, either version 1.3
|
||||
%% of this license or (at your option) any later version.
|
||||
%% The latest version of this license is in
|
||||
%% http://www.latex-project.org/lppl.txt
|
||||
%% and version 1.3 or later is part of all distributions of LaTeX
|
||||
%% version 2005/12/01 or later.
|
||||
%%
|
||||
%% This work has the LPPL maintenance status `author-maintained'.
|
||||
%%
|
||||
%% This work consists of all files listed in README.md
|
||||
%%
|
||||
\RequirePackage{l3keys2e}
|
||||
|
||||
\ProvidesExplPackage{csvsimple}{2023/10/16}{2.5.0}
|
||||
{LaTeX CSV file processing}
|
||||
|
||||
\cs_if_exist:NT \c__csvsim_package_expl_bool
|
||||
{
|
||||
\msg_new:nnn { csvsimple }{ package-loaded }
|
||||
{ Package~'#1'~seems~already~be~loaded! }
|
||||
\bool_if:NTF \c__csvsim_package_expl_bool
|
||||
{
|
||||
\msg_warning:nn { csvsimple }{ package-loaded }{ csvsimple-l3 }
|
||||
}
|
||||
{
|
||||
\msg_warning:nn { csvsimple }{ package-loaded }{ csvsimple-legacy }
|
||||
}
|
||||
\tex_endinput:D
|
||||
}
|
||||
|
||||
\keys_define:nn { csvsimple }
|
||||
{
|
||||
l3 .code:n = \tl_set:Nn \l__csvsim_package_expl_tl { l3 },
|
||||
legacy .code:n = \tl_set:Nn \l__csvsim_package_expl_tl { legacy },
|
||||
}
|
||||
|
||||
\keys_set:nn { csvsimple } { legacy }
|
||||
|
||||
\ProcessKeysPackageOptions { csvsimple }
|
||||
|
||||
\RequirePackage{csvsimple-\l__csvsim_package_expl_tl}
|
175
csvsimple/csvsimple.tex
Normal file
175
csvsimple/csvsimple.tex
Normal file
|
@ -0,0 +1,175 @@
|
|||
% \LaTeX-Main\
|
||||
% !TeX encoding=UTF-8
|
||||
%% The LaTeX package csvsimple - version 2.5.0 (2023/10/16)
|
||||
%% csvsimple.tex: Manual
|
||||
%%
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%% Copyright (c) 2008-2023 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
|
||||
%% -------------------------------------------------------------------------------------------
|
||||
%%
|
||||
%% This work may be distributed and/or modified under the
|
||||
%% conditions of the LaTeX Project Public License, either version 1.3
|
||||
%% of this license or (at your option) any later version.
|
||||
%% The latest version of this license is in
|
||||
%% http://www.latex-project.org/lppl.txt
|
||||
%% and version 1.3 or later is part of all distributions of LaTeX
|
||||
%% version 2005/12/01 or later.
|
||||
%%
|
||||
%% This work has the LPPL maintenance status `author-maintained'.
|
||||
%%
|
||||
%% This work consists of all files listed in README.md
|
||||
%%
|
||||
\documentclass[a4paper,11pt]{ltxdoc}
|
||||
\usepackage{csvsimple-doc}
|
||||
|
||||
\usepackage{\csvpkgprefix csvsimple-legacy}
|
||||
|
||||
\hypersetup{
|
||||
pdftitle={Manual for the csvsimple package},
|
||||
pdfauthor={Thomas F. Sturm},
|
||||
pdfsubject={csv file processing with LaTeX},
|
||||
pdfkeywords={csv file, comma separated values, key value syntax}
|
||||
}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\begin{document}
|
||||
\begin{center}
|
||||
\begin{tcolorbox}[enhanced,hbox,tikznode,left=8mm,right=8mm,boxrule=0.4pt,
|
||||
colback=white,colframe=black!50!yellow,
|
||||
drop lifted shadow=black!50!yellow,arc is angular,
|
||||
before=\par\vspace*{5mm},after=\par\bigskip]
|
||||
{\bfseries\LARGE The \texttt{csvsimple} package}\\[3mm]
|
||||
{\large Manual for version \version\ (\datum)}
|
||||
\end{tcolorbox}
|
||||
{\large Thomas F.~Sturm%
|
||||
\footnote{Prof.~Dr.~Dr.~Thomas F.~Sturm, Institut f\"{u}r Mathematik und Informatik,
|
||||
University of the Bundeswehr Munich, D-85577 Neubiberg, Germany;
|
||||
email: \href{mailto:thomas.sturm@unibw.de}{thomas.sturm@unibw.de}}\par\medskip
|
||||
\normalsize\url{https://www.ctan.org/pkg/csvsimple}\par
|
||||
\url{https://github.com/T-F-S/csvsimple}
|
||||
}
|
||||
\end{center}
|
||||
\bigskip
|
||||
\begin{absquote}
|
||||
\begin{center}\bfseries Abstract\end{center}
|
||||
|csvsimple| provides a simple \LaTeX\ interface for the processing of files with
|
||||
comma separated values (CSV). |csvsimple| relies heavily on a key value
|
||||
syntax which results in an easy way of usage.
|
||||
Filtering and table generation is especially supported. Since the package
|
||||
is considered as a lightweight tool, there is no support for data sorting
|
||||
or data base storage.
|
||||
\end{absquote}
|
||||
|
||||
\section{Package Options}%
|
||||
|
||||
|csvsimple| is a stub which merely selects to load exclusively one of the
|
||||
following packages:
|
||||
\begin{itemize}
|
||||
\item \href{csvsimple-l3.pdf}{\flqq The |csvsimple-l3| package\frqq}:\\
|
||||
This is the pure \LaTeX3 version of |csvsimple|. It is considered
|
||||
to be the \emph{current} version.
|
||||
New documents are encouraged to use this package.\par
|
||||
|csvsimple-l3| is loaded with \emph{one} of the following
|
||||
alternatives inside the preamble:
|
||||
\begin{dispListing}
|
||||
\usepackage[l3]{csvsimple}
|
||||
% or alternatively (not simultaneously!)
|
||||
\usepackage{csvsimple-l3}
|
||||
\end{dispListing}
|
||||
\medskip
|
||||
|
||||
\item \href{csvsimple-legacy.pdf}{\flqq The |csvsimple-legacy| package\frqq}:\\
|
||||
This is the \LaTeXe{} version of |csvsimple|. It is considered
|
||||
to be the \emph{superseded} version identical to version 1.22 of |csvsimple|.
|
||||
Documents based on that former version do \emph{not have to be changed}
|
||||
and stay compilable in future.\par
|
||||
|csvsimple-legacy| is loaded with \emph{one} of the following
|
||||
alternatives inside the preamble:
|
||||
\begin{dispListing}
|
||||
\usepackage{csvsimple}
|
||||
% or alternatively (not simultaneously!)
|
||||
\usepackage[legacy]{csvsimple}
|
||||
% or alternatively (not simultaneously!)
|
||||
\usepackage{csvsimple-legacy}
|
||||
\end{dispListing}
|
||||
\end{itemize}
|
||||
|
||||
|
||||
\clearpage
|
||||
\section{Differences between \texttt{csvsimple-l3} and \texttt{csvsimple-legacy}}
|
||||
This section is intended for users who know |csvsimple| before version~2.00.
|
||||
|
||||
|csvsimple-l3| is a \emph{nearly} drop-in replacement for
|
||||
|csvsimple-legacy|. Although old documents have no \emph{need} to be changed,
|
||||
adopting the new \LaTeX3 version for existing documents should impose not
|
||||
too much effort. Actually, it depends on how intense |pgfkeys| specific
|
||||
styles were used.
|
||||
|
||||
That brings us to the differences between the two packages and a more precise
|
||||
understanding what \emph{nearly} drop-in replacement means. The following enumeration
|
||||
does not list new features of \texttt{csvsimple-l3} (if any), but takes an
|
||||
upgrade point of view.
|
||||
|
||||
\begin{itemize}
|
||||
\item Any patches or additions using undocumented internals of |csvsimple-legacy|
|
||||
will stop to function, because |csvsimple-l3| has a completely implementation.
|
||||
\item |csvsimple-l3| is programmed in |expl3| code using the \LaTeX3 interfaces.
|
||||
No additional packages are loaded or needed with exception of several options
|
||||
which allow to access methods from |ifthen|, |etoolbox|, |longtable|, etc.
|
||||
On the other hand, |csvsimple-legacy| is programmed in \LaTeXe{} with
|
||||
dirty tricks from here and there.
|
||||
\item The most significant change of the user interface is that the key value
|
||||
engine of |csvsimple-legacy| is |pgfkeys| (root \docAuxKey*[csv]{}) while |csvsimple-l3| uses
|
||||
|l3keys| (root \docAuxKey*[csvsim]{}).
|
||||
Names and usage of the keys are \emph{unchanged}.
|
||||
But, if
|
||||
you made own |pgfkeys| \emph{styles} using the |pgfkeys| style handler,
|
||||
these \emph{styles} have to be adapted to |.meta| keys of |l3keys|.
|
||||
The good news is that styles
|
||||
made with \docAuxCommand*{csvstyle} become |.meta| keys automatically.
|
||||
\item The macro \docAuxCommand*{csvheadset} is removed. It is not supportable
|
||||
by the new implementation. I never used it and I forgot why I ever wrote it
|
||||
-- I hope the same is true for you. If not, |csvsimple-legacy| can be
|
||||
used for documents which needs it.
|
||||
\item Option \docAuxKey*[csv]{filter} is removed. Instead, \docAuxKey*[csvsim]{filter ifthen}
|
||||
can be used (also true with \docAuxKey*[csv]{filter ifthen} for the old version).
|
||||
\item The deprecated options
|
||||
\docAuxKey*[csv]{nofilter} and \docAuxKey*[csv]{nohead} are removed.
|
||||
They were not documented any more since years. Obviously, use
|
||||
\docAuxKey*[csvsim]{no filter} and \docAuxKey*[csvsim]{no head} instead.
|
||||
\item Compilation problems are to be expected, if an |S| column of the |siunitx| package
|
||||
is used as first or last column. Documents neglecting this rule successfully
|
||||
for |csvsimple-legacy|, may fail to compile with |csvsimple-l3.|
|
||||
\item The \LaTeX{} counters \docCounter*{csvinputline}
|
||||
and \docCounter*{csvrow}
|
||||
are replaced by \LaTeX3 integers
|
||||
\docCounter*{g_csvsim_inputline_int}
|
||||
and \docCounter*{g_csvsim_row_int}, but accessors
|
||||
\docAuxCommand*{thecsvinputline} and
|
||||
\docAuxCommand*{thecsvrow} are still valid.
|
||||
\item The packages |pgfrcs|, |pgfkeys|, |ifthen|, |etoolbox|, and |shellesc|
|
||||
are not included anymore (include manually, if needed).
|
||||
\item
|
||||
\docAuxCommand*{csviffirstrow} and
|
||||
\docAuxCommand*{csvifoddrow} are deprecated and replaced by
|
||||
\docAuxCommand*{ifcsvfirstrow}
|
||||
\docAuxCommand*{ifcsvoddrow}
|
||||
which are more consistent in nomenclature.
|
||||
\item For |csvsimple-l3|, data lines are allowed to begin with an backslash.
|
||||
\item Assigned macros like |\myname| for e.g. the third column contain
|
||||
not |\csvcoliii| anymore, but are equal to the content of |\csvcoliii| now.
|
||||
\item Character code changes with \docAuxKey*[csvsim]{respect percent} etc.
|
||||
and the tabulator as separator should work for |csvsimple-l3| as expected in every
|
||||
situation (not always worked for |csvsimple-legacy|).
|
||||
\item A drawback of |csvsimple-l3| against |csvsimple-legacy| is
|
||||
a higher compilation time. This may vary by used compiler.
|
||||
An example document of 5061 pages using a CSV file with 166 992 lines
|
||||
took about 28 seconds with |csvsimple-legacy| and
|
||||
about 51 seconds with |csvsimple-l3| on my machine
|
||||
(just a singular observation, no scientific analysis at all).
|
||||
\end{itemize}
|
||||
|
||||
|
||||
|
||||
|
||||
\end{document}
|
6
csvsimple/encoding.xml
Normal file
6
csvsimple/encoding.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<csv>
|
||||
<noHeader/>
|
||||
<bracket empty="true"/>
|
||||
<charset in="windows-1252" out="UTF-8"/>
|
||||
</csv>
|
9
csvsimple/gradesort.xml
Normal file
9
csvsimple/gradesort.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<csv>
|
||||
<bracket empty="true" />
|
||||
<sortlines>
|
||||
<column name="grade" order="ascending" type="double"/>
|
||||
<column name="name" order="ascending" type="string"/>
|
||||
<column name="givenname" order="ascending" type="string"/>
|
||||
</sortlines>
|
||||
</csv>
|
7
csvsimple/matriculationsort.xml
Normal file
7
csvsimple/matriculationsort.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<csv>
|
||||
<bracket empty="true" />
|
||||
<sortlines>
|
||||
<column name="matriculation" order="ascending" type="integer"/>
|
||||
</sortlines>
|
||||
</csv>
|
8
csvsimple/namesort.xml
Normal file
8
csvsimple/namesort.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<csv>
|
||||
<bracket empty="true" />
|
||||
<sortlines>
|
||||
<column name="name" order="ascending" type="string"/>
|
||||
<column name="givenname" order="ascending" type="string"/>
|
||||
</sortlines>
|
||||
</csv>
|
7
csvsimple/transform.xml
Normal file
7
csvsimple/transform.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<csv>
|
||||
<bracket leftsymbol="doublequote" rightsymbol="doublequote" />
|
||||
<delimiter signsymbol="semicolon" />
|
||||
<outBracket leftsymbol="braceleft" rightsymbol="braceright" />
|
||||
<outDelimiter signsymbol="comma" />
|
||||
</csv>
|
114
document.tex
Normal file
114
document.tex
Normal file
|
@ -0,0 +1,114 @@
|
|||
|
||||
|
||||
\documentclass[fontsize=12pt]{scrlttr2}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{%
|
||||
ngerman,
|
||||
ae,
|
||||
times, %% hier kann man die Schriftart einstellen
|
||||
graphicx,
|
||||
url}
|
||||
\usepackage{eurosym}
|
||||
\usepackage{pdfpages}
|
||||
\usepackage{nopageno}
|
||||
\usepackage{array}
|
||||
\usepackage{makecell}
|
||||
\usepackage{csvsimple}
|
||||
|
||||
% Hier die Optionen fuer scrlttr2 eintragen.
|
||||
% S.a. scrguide.pdf ab Seite 150
|
||||
\KOMAoptions{paper=a4,fromalign=center,fromrule=aftername,
|
||||
backaddress=true,parskip=half,enlargefirstpage=true}
|
||||
|
||||
% Falls man das alte scrlettr vemisst, oder die Option
|
||||
% "enlargefirstpage=true" aus den KOMAoptions
|
||||
% benutzen will, muss man den folgenden Eintrag
|
||||
% auskommentieren (einfach das %-Zeichen löschen).
|
||||
%\LoadLetterOption{KOMAold}
|
||||
|
||||
% hier Name und darunter Anschrift einsetzen:
|
||||
\setkomavar{fromname}{CCL}
|
||||
\setkomavar{fromaddress}{Oberhafen\\
|
||||
Hamburg}
|
||||
|
||||
% hier die Signatur einsetzen:
|
||||
\setkomavar{signature}{Sebastian Hinz}
|
||||
|
||||
% hier betreff einsetzen
|
||||
\setkomavar{subject}{Spendenquittung}
|
||||
|
||||
% hier kommt dein Ort hin:
|
||||
\setkomavar{place}{Hamburg}
|
||||
|
||||
% die Signatur ist linksbuendig
|
||||
\let\raggedsignature=\raggedright
|
||||
|
||||
% Manche finden, dass scrlttr2 so eine riesige Fußzeile hat
|
||||
% einfach die nächste Zeile auskommentieren, dann wird sie kleiner:
|
||||
% \setlength{\footskip}{-6pt}
|
||||
|
||||
% pdflatex \"\\newcommand{\\vorname}{#{vorname}}
|
||||
% \\newcommand{\\nachname}{#{name}}
|
||||
% \\newcommand{\\strasse}{#{strasse + " " + hausnummer.to_s}}
|
||||
% \\newcommand{\\plz}{#{plz}}
|
||||
% \\newcommand{\\ort}{#{ort}}
|
||||
% \\newcommand{\\betrag}{#{betrag}}
|
||||
% \\newcommand{\\betraginworten}{#{betrag_in_worten}}
|
||||
% \\newcommand{\\startdatum}{#{start_datum}}
|
||||
% \\newcommand{\\findatum}{#{end_datum}}
|
||||
% \\newcommand{\\mitgliedsnummer}
|
||||
|
||||
\begin{document}
|
||||
% die Anschrift des Empfaengers
|
||||
\begin{letter}{\vorname{} \nachname{} \\
|
||||
\strasse{}\\
|
||||
\plz{} \ort{}}
|
||||
|
||||
\opening{Sehr geehrte Damen und Herren,}
|
||||
|
||||
Mitgliedsnummer: \mitgliedsnummer{}\\
|
||||
Betrag: \betrag{} \euro{}\\
|
||||
Betrag in worten: \betraginworten{}\\
|
||||
Zeitraum: \startdatum{} - \findatum{}\\
|
||||
|
||||
%\csvautotabular{payments.csv}
|
||||
|
||||
\csvreader[
|
||||
tabular=|l|l|l|l|,
|
||||
table head=\hline \thead{ Datum der Zuwendung} & \thead{Art der Zuwendung \\ (Geldzuwendung/Mitgliedsbeitrag)} & \thead{Verzicht auf die Erstattung\\ von Aufwendungen (ja/nein)} & Betrag\\\hline,
|
||||
late after line=\\\hline,
|
||||
]{payments.csv}{datum=\datum,betrag=\betrag,type=\type,verzicht=\verzicht}%
|
||||
{\datum & \type & \verzicht &\betrag \euro{}}%
|
||||
% {\csvcoli & \csvcolii}
|
||||
|
||||
\closing{Mit freundlichen Grüßen}
|
||||
|
||||
|
||||
|
||||
\end{letter}
|
||||
\end{document}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue