0

I have Coordinate files in txt format looking like this (tab delimited):

Name   X    Y    Z

K1     323  123  321

K2     132  342  434

...etc until K4.

I need to write a python script to copy the contents of these txt files, and paste them into an Excel sheet. The problem is that I cannot figure out how to paste the coordinates below the last row with existing data. There is no solution for this from what I have found.

Since I will be doing this many times with different files, the coordinates need to continuosly be placed below the last line with data.

Is this possible? I have successfully moved the contents to A1 in the excel sheet using this code:

import pandas as pd

df = pd.read_table('Coordinates.txt') 

df.to_excel('Test.xlsx', 'Sheet1')

Please understand that I am very new to Python, and have really tried to scan the internet for a solution that fits my needs.

Any help appreciated.

  • Possible duplicate of [How to convert data from txt files to Excel files using python](https://stackoverflow.com/questions/51828811/how-to-convert-data-from-txt-files-to-excel-files-using-python) – sahasrara62 Oct 09 '19 at 14:09
  • Read about [pandas.DataFrame.append](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.append.html?highlight=append#pandas.DataFrame.append) – stovfl Oct 09 '19 at 14:22

0 Answers0