Package: csv2numbers
Converter for CSV to Apple Numberscsv2numbersis a command-line utility to convert CSV files to Apple Numbers spreadsheets.Installationpython3-mpipinstallcsv2numbersA pre-requisite for this package ispython-snappywhich will be installed by Python automatically, but python-snappy also requires that the binary libraries for snappy compression are present.The most straightforward way to install the binary dependencies is to useHomebrewand source Python from Homebrew rather than from macOS as described in thepython-snappy github:For Intel Macs:brewinstallsnappypython3CPPFLAGS="-I/usr/local/include -L/usr/local/lib"python3-mpipinstallpython-snappyFor Apple Silicon Macs:brewinstallsnappypython3CPPFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib"python3-mpipinstallpython-snappyFor Linux (your package manager may be different):sudoapt-get-yinstalllibsnappy-devOn Windows, you will need to either arrange for snappy to be found for VSC++ or you can install python binary libraries compiled byChristoph Gohlke. You must select the correct python version for your installation. For example for python 3.11:C:\Users\Jon>pip install C:\Users\Jon\Downloads\python_snappy-0.6.1-cp311-cp311-win_amd64.whlUsageUsecsv2numbersto print command-line usage. You must provide at least one CSV file on the command-line and can provide multiple files, which will then all be converted using the same parameters. Output files can optionally be provided, but is none are provided, the output is created by replacing the input's files suffix with.numbers. For example:csv2numbers file1.csv file2.csv -o file1.numbers file2.numbersCSV files are read using the Excel dialect.The following options affecting the output of the entire file. The default for each is always false.--whitespace: strip whitespace from beginning and end of strings and collapse other whitespace into single space--reverse: reverse the order of the data rows--no-header: CSV file has no header row--day-first: dates are represented day first in the CSV filecsv2numberscan also perform column manipulation. Columns can be identified using their name if the CSV file has a header or using a column index. Columns are zero-indexed and names and indices can be used together on the same command-line. When multiple columns are required, you can specify them using comma-separated values. The format for these arguments, like for the CSV file itself, the Excel dialect.Deleting columnsDelete columns using--delete. The names or indices of the columns to delete are specified as comma-separated values:csv2numbers file1.csv --delete=Account,3Renaming columnsRename columns using--rename. The current column name and new column name are separated by a:and each renaming is specified as comma-separated values:csv2numbers file1.csv --rename=2:Account,"Paid In":AmountDate columnsThe--dateoption identifies a comma-separated list of columns that should be parsed as dates. Use--day-firstwhere the day and month is ambiguous anf the day comes first rather than the month.Transforming columnsColumns can be merged and new columns created using simple functions. The--transformoption takes a comma-seperated list of transformations of the formNEW:FUNC=OLD. Supported functions are:FunctionArgumentsDescriptionMERGEdest=MERGE:sourceThedestcolumn is writen with values from one or more columns indicated bysource. For multiple columns, which are separated by;, the first empty value is chosen.NEGdest=NEG:sourceThedestcolumn contains absolute values of any column that is negative. This is useful for isolating debits from account exports.POSdest=NEG:sourceThedestcolumn contains values of any column that is positive. This is useful for isolating credits from account exports.LOOKUPdest=LOOKUP:source;filenameA lookup map is read fromfilenamewhich must be an Apple Numbers file containing a single table of two columns. The table is used to match agsinstsource, searching the first column for matches and writing the corresponding value from the second column todest. Values are chosen based on the longest matching substring.Examples:csv2numbers --transform="Paid In"=POS:Amount,Withdrawn=NEG:Amount file1.csv
csv2numbers --transform='Category=LOOKUP:Transaction;mapping.numbers' file1.csvLicenseAll code in this repository is licensed under theMIT License