generate PDF document on UNIX (not with GUI) from SQL*Plus output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting generate PDF document on UNIX (not with GUI) from SQL*Plus output
# 1  
Old 04-12-2011
generate PDF document on UNIX (not with GUI) from SQL*Plus output

Hi

I wish to generate from CSV output of SQL*Plus a PDF. I use a Solaris 10 box. Which Open Source software can do that on CLI?
# 2  
Old 04-12-2011
Have a look at CsvToPdf.py
# 3  
Old 04-12-2011
Code:
$ python CsvToPdf.py output.csv test.pdf
python: can't open file 'CsvToPdf.py': [Errno 2] No such file or directory

Howto install 'CsvToPdf.py'? Where to download?
# 4  
Old 05-10-2011
any other idea?
# 5  
Old 05-10-2011
Sure. There are lots of Python text to PDF converters out there.

For example, a popular one is ReportLab.

Here is a short simple example of how to convert a CSV file called names.csv to a PDF file called names.pdf

The format of the CSV file is:
Code:
"last1","first1"
"last2","first2"
....

Code:
import csv
from reportlab.pdfgen import canvas
from reportlab.lib.units import cm, inch, mm

PAGE_WIDTH = 8.5 * inch
PAGE_HEIGHT = 11 * inch

def process_csvfile(filename):
    data =  []
    csvfile = csv.reader(open(filename))
    for row in csvfile:
        newdata = [row[0],row[1]]
        data.append(newdata)
    return data

def gen_file(data, filename):
    c = canvas.Canvas(filename)
    c.setFont('Times-Bold', 18)
    c.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT - 0.5*inch, "Demonstration")
    c.setFont('Times-Roman',9)

    i=0;
    for first, last in data:
       print last, first
       str = last + ', ' + first
       c.drawString(1*inch, PAGE_HEIGHT - (1 + 0.25*i)*inch, str)
       i = i+1;

    c.showPage()
    c.save()
    return

data = process_csvfile('names.csv')
gen_file(data, "names.pdf")

There are also a number of commercial utilities out there that directly convert spooled output to PDF.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

2. Shell Programming and Scripting

SQL output to UNIX variable

I have a sql statement , i need to assign to a variable in Unix sel count(*) AS num_files from TABLE_A; i need to use "num_files" in unix statements. let me know how to assign unix variable to above num_files (1 Reply)
Discussion started by: nani1984
1 Replies

3. Shell Programming and Scripting

Redirect output from SQL to unix variable

Hi, I have a requirement to store oracle sqlplus output to some unix variable, count the records and then print the output on the screen. Can you please point me to any sample program for reference purpose. Thanks a lot for your time. (0 Replies)
Discussion started by: bhupinder08
0 Replies

4. Shell Programming and Scripting

Read a CSV file and generate SQL output

Friends, This is what I need: I will pass a CSV file as an input, and I want my shell to be reading that CSV file, and based on the parameters it should generate SQLs and write those SQL in a different file in the same location. I'm new to Shell scripting. I'm currently working on a... (25 Replies)
Discussion started by: Ram.Math
25 Replies

5. Shell Programming and Scripting

to read a CSV file and generate SQL output

Friends, This is what I need: I will pass a CSV file as an input, and I want my shell to be reading that CSV file, and based on the parameters it should generate SQLs and write those SQL in a different file in the same location. I'm new to Shell scripting. I'm currently working on a... (1 Reply)
Discussion started by: Ram.Math
1 Replies

6. Shell Programming and Scripting

generate tabular output from an input text file in unix shell scripting

Hi, I have the output (as below) which i want it to be in a table. For e.g. space utilization in PSE on path /logs is 0% space utilization in PSE on path /logs/tuxedo/tuxlsp is 16% space utilization in PSE on path /ldvarlsp/lsp/log is 37% space utilization in PSE on path /home is 6%... (7 Replies)
Discussion started by: pkbond
7 Replies

7. Shell Programming and Scripting

Output of Unix & SQL in same file

output of Unix & sql in same file hi all, am working on shell script, i need to format data in such a way that both my Unix commands output & my sql output should be in a same file. I am able to redirect both output in separate files. for sql output: sqlplus -s... (6 Replies)
Discussion started by: bankimmehta
6 Replies

8. UNIX for Dummies Questions & Answers

Converting LATEX PDF to WORD document

Hi there, is it possible to convert pdf files to Word with some free :p software or with some trick??? Now I'm working with LATEX and I can get pdf format but I would like to get .rtf or .doc files too:rolleyes:. Lately I found something like that, but it wasn't free. Thanks for any... (1 Reply)
Discussion started by: Giordano Bruno
1 Replies

9. UNIX for Dummies Questions & Answers

How to conver a unix output file to Microsoft word document

Hi, I'am are working on Unix platform. It requires for me to present the certain unix files in Microsoft word. Is conversion of a Unix ".out" file to Microsoft word feasible????? Kindly Let me know on this... Thanks in Advance, Divya (1 Reply)
Discussion started by: divyacl
1 Replies
Login or Register to Ask a Question