AgTalk Home
AgTalk Home
Search Forums | Classifieds (34) | Skins | Language
You are logged in as a guest. ( logon | register )

Trim a column in a spreadsheet?
View previous thread :: View next thread
   Forums List -> Computer TalkMessage format
 
Don Smith
Posted 12/12/2019 10:53 (#7902513 - in reply to #7901430)
Subject: RE: Trim a column in a spreadsheet?



Centre county Pennsylvania, USA
Yup,

I don't do Microsoft stuff so can't comment on your code Dave, but here is how to do it better:

(1) get a Linux machine and install Pandas and Python 3.2 or above with idle3.

(2) read your .csv file into a pandas dataframe.

(3) parse each column of that data frame into python lists.

(4) slice (trim) those lists with python to get whatever range of data wanted.

(5) print the sliced (trimmed) data, and/or plot it using python's matplotlib.

The actual code required to read the .csv file and print sliced (trimmed) columns can be very small if you write a python method called print_trimmed_columns that does it for you and call that method. For example, if you wanted to print columns trimmed to 100 data points, the code would be:

trimsize = 100
print_trimmed_columns(csv_file,trimsize)

Not only is that smaller code that the Microsoft stuff, it's much more readable code. Python is self documented by using names that are common sense English, not computer goobly gook.

Edit to add:

Here is a link that explains how to change column names in pandas:

https://stackoverflow.com/questions/11346283/renaming-columns-in-pan...
Top of the page Bottom of the page


Jump to forum :
Search this forum
Printer friendly version
E-mail a link to this thread

(Delete cookies)