combine two files into one list

This is the place for queries that don't fit in any of the other categories.

combine two files into one list

Postby systemWeb » Sun Oct 20, 2013 7:00 pm

Hello, I have 2 different text files with numerical data can i use one function to open the two files and create a combined list in python?

My files look something like this...
Code: Select all
StudentFees1_Oct
45
59
99
109

Code: Select all
StudentFees2_Sept
79
33
55
111


the combined list would look like this ....
Code: Select all
[45, 59, 99, 109, 79, 33, 55, 111]
Last edited by Mekire on Sun Oct 20, 2013 7:03 pm, edited 1 time in total.
Reason: Code tags. First post lock. Please read "New Users" thread.
systemWeb
 
Posts: 2
Joined: Sun Oct 20, 2013 6:55 pm

Re: combine two files into one list

Postby stranac » Sun Oct 20, 2013 7:28 pm

I don't thinks there's a function that will do that.
You'll have to write some code yourself to achieve that, but it shouldn't be too hard.
Just loop through the files, convert stuff to ints(if needed), and append them to a list.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1218
Joined: Thu Feb 07, 2013 3:42 pm

Re: combine two files into one list

Postby systemWeb » Sun Oct 20, 2013 9:11 pm

Thanks for the reply and pointers Stranac.
systemWeb
 
Posts: 2
Joined: Sun Oct 20, 2013 6:55 pm


Return to General Coding Help

Who is online

Users browsing this forum: mdovey, Mekire and 2 guests