2

I have a CSV file. I need to print this file row by row.

For example, each row contains name, surname, email, profession and so on, many columns. First row contains the column titles. I would like to print each row on one page. Each data should print like this:

Name: John
Surname: Doe
Email: [email protected] 

etc, where Name and Surname and Email column names come from the CSV's first row.

Now I'd need to print, let's say 100 rows like this, automatically, from the CSV file. How can I achieve that? I could also do a little programming if necessary.

4
  • 2
    Product recommendations are off topic for SU. So I should not recommend open office's calc. :)
    – Hennes
    Commented Jan 17, 2013 at 17:30
  • 1
    Well, I'd say this is a specific enough question so as not to become not constructive. I reworded it a little. It doesn't really need to be closed.
    – slhck
    Commented Jan 17, 2013 at 20:32
  • Open the file in a spreadsheet program (Open Source ones are available) make sure it's lined up like you want, and print it. Another idea is to import the CSV into an open source SQL (like PostgreSQL) and the use PHP and JavaScript to format it/pint it.
    – Everett
    Commented Jan 17, 2013 at 22:03
  • Actually, I've created this question after being unable to do it with Calc. At least, nothing like this in menu. Again, I need one record (=1 row) per page, vertically (as specified above). As for using PHP and SQL: yes, perhaps I'll do it like this if all else fails, however, this requires writing a program and setting up a server on a computer. I thought that maybe there is a 5 min solution. Perhaps it's too exotic problem to have a (almost) ready solution. I'll also take a look at Calc macros.
    – camcam
    Commented Jan 18, 2013 at 18:46

1 Answer 1

1

This can be done with Powershell:

  1. Import-Csv file

  2. for each row, construct a string

  3. Send that string to the printer using the Out-Printer cmdlet

So a script would look something like:

Import-Csv .\process.csv | foreach { "Name:$($_.Name)`nPath:$($_.Path)`nProduct:$($_.Product)" | Out-Printer}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .