mitreac / b575f19

UM DCMB BIOINF 575 Fall 2019 class repo
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link

[QUESTION] Example code question #1

Open betteridiot opened 5 years ago

betteridiot commented 5 years ago

Instructions


Question (continued)

This is an example coding question that will demonstrate how to use this question temple. The example here is how to parse a comma separated file.


What do you have?

I have a text file named foo.csv. That means my input is a str that references the path to a text file. Additionally, the values in foo.csv are separated by a ,. This means that my delimiter is a str as well.

The content of this file are:

1,2,3
a,b,c

What do you need?

I expect that this code should be able to open up the file and process it line-by-line and give me the values as a list


What have you done?

If this is a coding question

Every time I open the program, it only gives me the last line of the file instead of each of the lines

User-written code

file = open('foo.bar')
for line in file:
    parsed)_line = line.split(',')
print(line)

Observed error messages

# Paste the observed error messages here

Observed output of code (other than error messages)

# Paste the output of your coding attempts here
[ 'a', 'b', 'c']

Checklist

Replace the space in between the brackets with an X