Sponsored Content
Top Forums Programming Appending a column in xlsx file using Python Post 302999776 by nans on Tuesday 27th of June 2017 05:19:18 PM
Old 06-27-2017
Quote:
Originally Posted by durden_tyler
1) Remove the parameter, not the function call. In other words, do call the function, but don't pass any parameter to it.

2) Change the signature of the function so that it does not accept any parameter.

3) Call the function only once. Calling the same function that reads the same text file and returns the same dictionary every time you find an Excel spreadsheet is extremely inefficient.

4) Check what you are trying to print.
Code:
pos_col_no = 'E'
alt_col_no = 'G'
ref_col_no = 'F'
row_no = 4

So,
Code:
pos_col_no + alt_col_no + ref_col_no + str(row_no) = 'EGF4'

There is no cell called "EGF4" in any Excel spreadsheet.
Hence Python cannot print it.
>>> Ok, that's a wrong statement. My bad, sorry. Looks like newer versions of Microsoft Excel do have cell "EGF4".
>>> That may not be the cell you want to print. My guess is that your program is printing "None" instead of nothing.
>>> Your spreadsheet's cell "EGF4" is empty, most likely.
I'm using Libre Office, an older version, not microsoft excel. So what would be the appropriate way of calling E4:G4:F4 -> V4

What do you mean by point 2 ? Will.it then be
dpos = get_text_data(txt_filename)

Last edited by nans; 06-27-2017 at 07:40 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending a column in one file to the corresponding line in a second

It appears that this has been asked and answered in similar fashions previously, but I am still unsure how to approach this. I have two files containing user information: fileA ttim:/home/ttim:Tiny Tim:632 ppinto:/home/ppinto:Pam Pinto:633 fileB ttim:xkfgjkd*&#^jhdfh... (3 Replies)
Discussion started by: suzannef
3 Replies

2. Shell Programming and Scripting

Appending 'string' to file as first column.

Hi , I have the below file with 6 columns.I want to append 'File1' as the 1 column to the file. i have the sample code .It is not working . can u please correct this or make new one ..... awk 'print {'File1',$1,$2,$3,$4,$5,$6}' Source_File> Result_File Source_File:... (6 Replies)
Discussion started by: satyam_sat
6 Replies

3. Shell Programming and Scripting

appending column file

Hi all, I have two files with the same number of lines the first file is a.dat and looks like 0.000 1.000 1.000 2.000 ... the fields are tab separated the second file is b.dat and looks like 1.2347 0.546 2.3564 0.321 ... the fields are tab separated I would like to have a file c.dat... (4 Replies)
Discussion started by: f_o_555
4 Replies

4. UNIX for Dummies Questions & Answers

Appending date value mmdd to first column in file

Hi , I have a file with a running sequence number. I need to append a date value mmdd format on to the first column. for e.g.: The file contains records as 001 abc 002 cde 003 edf 004 fgh 005 hik The output should be 1111001 abc 1111002 cde 1111003 edf 1111004 ... (1 Reply)
Discussion started by: kalyansid
1 Replies

5. Shell Programming and Scripting

Appending new column to existing files

Hi, i want to add another column to existing files containing strings and need to have the final output as a csv file. i have quite a number of files, each with varying number of rows and i need to append the string "test" for all the valid rows for each file. my sample raw files looks like this... (8 Replies)
Discussion started by: ida1215
8 Replies

6. UNIX for Dummies Questions & Answers

Appending a column of numbers in ascending order to a text file

I have a text file where I want to append a column of numbers in ascending orders. Input: 57 abc 25 def 32 ghi 54 jkl Output:57 abc 57 abc 1 25 def 2 32 ghi 3 54 jkl 4 How do I go about doing that? Thanks! (11 Replies)
Discussion started by: evelibertine
11 Replies

7. Shell Programming and Scripting

Appending column to rows

Hi All, Input.txt KGO Id "003" .......... .......... Par "CPara" BIN RECGET Name "DIR_PATH" Prompt "DIR_PATH" END RECGET KGO ............ .......... ............... KGO Id "077" .......... .......... (7 Replies)
Discussion started by: unme
7 Replies

8. Shell Programming and Scripting

Appending = in particular column in csv file

Hi, I have a requirement to append = in particular row in csv file. Data in csv is as follow: row1,a,a,a row2,b,b,b row3,c,c,c row4,d,d,d csv should be modified at row3 and no. of columns are not fixed but rows are. output should be as: row1,a,a,a row2,b,b,b row3,=c,=c,=c... (2 Replies)
Discussion started by: Divya1987
2 Replies

9. Shell Programming and Scripting

Python soap and string to .xlsx conversion

Hi experts - I'm relatively new to python, but I have an requirement to automate getting a file from a WebLib server using an API. The file I'm requesting from this sever is an excel spreadsheet (.xlsx). I get a valid response back via an xml doc from the server. In this xml file I get... (8 Replies)
Discussion started by: timj123
8 Replies

10. UNIX for Beginners Questions & Answers

How to insert data into black column( Secound Column ) in excel (.XLSX) file using shell script?

Source Code of the original script is down below please run the script and try to solve this problem this is my data and I want it column wise 2019-03-20 13:00:00:000 2019-03-20 15:00:00:000 1 Operating System LAB 0 1 1 1 1 1 1 1 1 1 0 1 (5 Replies)
Discussion started by: Shubham1182
5 Replies
RUNXLRD(1)						      General Commands Manual							RUNXLRD(1)

NAME
runxlrd - extract data from Microsoft Excel spreadsheet files SYNOPSIS
runxlrd [options] command [input-file-patterns] DESCRIPTION
This manual page documents briefly the runxlrd command. runxlrd offers a commandline interface to the Python xlrd module; it extracts data from Microsoft Excel spreadsheet files. OPTIONS
-h, --help Show summary of options and exit. -l logfilename Contains error messages. -v verbosity, --verbosity=verbosity Level of information and diagnostics provided. -p pickleable, --pickleable=pickleable 1: ensure Book object is pickleable (default); 0: don't bother. -m mmap, --mmap=mmap 1: use mmap; 0: don't use mmap; -1: accept heuristic. -e encoding, --encoding=encoding Encoding override. -f formatting, --formatting=formatting 0 (default): no fmt info 1: fmt info (all cells) 2: fmt info (margins trimmed). -g gc, --gc=gc 0: auto gc enabled; 1: auto gc disabled, manual collect after each file; 2: no gc. -s onesheet, --onesheet=onesheet Restrict output to this sheet (name or index). COMMANDS
Valid commands are o dump o count_records o version o hdr o ov o show o 2rows o 3rows o bench o names o name_dump o labels o xfc o hotshot o profile See the xlrd API documentation for the meaning of these commands. EXAMPLES
To show the first, second and last rows of each sheet in each file, run $ runxlrd 3rows *blah*.xls Run $ runxlrd -e koi8_r 3rows myfile.xls to explicitly pass the needed codepage to xlrd, e.g. if the codepage record is missing, or if it exists but is wrong. SEE ALSO
The xlrd API documentation, shipped in the file xlrd.html. The xlrd website <http://www.lexicon.net/sjmachin/xlrd.htm>. AUTHOR
runxlrd was written by John Machin. This manual page was written by Joost van Baal <joostvb+debian@uvt.nl>, for the Debian project (but may be used by others). xlrd 0.6.1a4 2007-05-24 RUNXLRD(1)
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy