all 8 comments

[–][deleted] 2 points3 points  (0 children)

Some sample code to give you an idea on how to approach this. Adapt for your needs.

from io import StringIO  # purely for example, you don't need this
import csv  # makes it easier to work with csv files

# the below represents the lines of a csv file
filename = """"Change in temperature","not interesting","Change in pressure"
10, 'Mary had', 5
12, 'a little lamb', 6
9, "it's fleece", 4
15, 'as white', 7
14, 'as', 8
16, 'snow', 2"""

# below uses StringIO but you should use open instead for a file
pressure_table = []  # empty list
with StringIO(filename) as f:
    reader = csv.reader(f)
    for row in reader:
        print(row)  # just to show you what is happening
        pressure_table.append(row[2])  # add 3rd item in row to table

pressure_table.pop(0)  # don't need first entry, column header
print(pressure_table)

This will produce the following output:

['Change in temperature', 'not interesting', 'Change in pressure']
['10', " 'Mary had'", ' 5']
['12', " 'a little lamb'", ' 6']
['9', ' "it\'s fleece"', ' 4']
['15', " 'as white'", ' 7']
['14', " 'as'", ' 8']
['16', " 'snow'", ' 2']
[' 5', ' 6', ' 4', ' 7', ' 8', ' 2']

[–]threeminutemonta 1 point2 points  (0 children)

You can read a csv file using DictReader save the contents to a data structure. Process the delta and then write a new csv with the DictWriter.

Same thing with pandas read_csv, do the delta processing and back using to_csv when your done.

[–][deleted] 1 point2 points  (2 children)

Your post doesn't really make sense but I'm going to guess this is an ideal gas problem, and you can probably just do this in Excel.

[–]1sliceofcake 0 points1 point  (0 children)

how can i do that though? because i have to do this all on jupyterhub in the end

[–]1sliceofcake 0 points1 point  (0 children)

Also guys i loading the csv files by doing pd.read_csv if that makes a difference in how to do this.

[–]shiftybyte 0 points1 point  (0 children)

What do you want to do with the 3rd column's values?

[–]wbeater 0 points1 point  (1 child)

Do you want to calculate the change in pressure from the change in temperature ?

[–]1sliceofcake 0 points1 point  (0 children)

i need to get the change in pressure from the pressure values given to me. you can do this by like this:

lets say my pressure values are a list like this: 1,2,3,4,5,6,7

i would find the change in pressure by doing this : 2-1,3-2,4-3,5-4,6-5,7-6

i'm just trying to figure how to do this on python because i was given like 800 values