0

I would like to build a python3 script that will download a CSV file every day and send it to me by mail. I have managed to download the file and sending the mail. The problem is the filtering. The CSV file contains

"155;03155;Northeim;1669;1261.7;9;35;0;131.55;66;49.9" 

and I want to filter only the last value 49.9 and send it to me by mail. This Value changes daily. But the order of the values doesn't.

Can someone help me?

4
  • 1
    does your CSV file only have 1 row or multiple rows? Commented Mar 22, 2021 at 11:21
  • for multiple rows I would use pandas df.iloc[:, -1] Commented Mar 22, 2021 at 11:26
  • I'd just use csv.reader - docs.python.org/3/library/csv.html - set your delimiter to ";", and take field [10] Commented Mar 22, 2021 at 11:28
  • @vishal Singh It only has 1 row Commented Mar 22, 2021 at 11:45

1 Answer 1

1

If your CSV file only contains 1 row then read the file, split at ; and access the last element of the list using [-1].

with open('your_csv_file.csv') as fp:
    value = fp.read().split(';')[-1]
Sign up to request clarification or add additional context in comments.

1 Comment

thank you very much, it worked perfectly :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.