[GLLUG] Digests of CSV files

John Edwards john at cornerstonelinux.co.uk
Fri Jan 5 19:27:42 UTC 2018


Hi

On Fri, Jan 05, 2018 at 07:09:53PM +0000, Bernard Peek via GLLUG wrote:
> On 05/01/18 18:11, John Levin via GLLUG wrote:
>> Dear list,
>> 
>> I'm having a bad google day, and am not sure what terms to search
>> on, so I hope the list will point me in the right direction.
>> 
>> I have a number of csv files (of c18th imprisoned debtors). There
>> are three important columns: gender, prison, trade. What I want is
>> a program or script that will simply digest each column and relate
>> them to each other, producing something along the lines of:
>> There are 200 weavers.
>> There are 190 male weavers.
>> There are 20 weavers in Norwich Castle.
>> There are 18 male weavers in Norwich Castle.
> 
> My approach would be to load the data into a database and write SQL
> queries against it. Second-best solution would probably be a
> spreadsheet. But if you want to write scripts then I suppose perl or
> awk are candidates.

The Perl DBI has a CSV driver which sounds like a sick joke but does
actually work. Once you load the CSV files as database tables you can
run SQL statements such as SELECT on them. For the very brave you can
even write to the files using SQL or create new tables (as CSV files).


-- 
#---------------------------------------------------------#
|    John Edwards   Email: john at cornerstonelinux.co.uk    |
#---------------------------------------------------------#
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20180105/d558dfac/attachment.sig>


More information about the GLLUG mailing list