Open Source Development Tutorials | About Us
Search  

Go Back   Open Source Tutorials Forum > Programming Languages > Python Programming
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-24-2008, 09:40 PM
masha2011 masha2011 is offline
Junior Member
 
Join Date: Jul 2008
Posts: 1 masha2011 is on a distinguished road
Default Reading specific lines from file and writing them another file

Hello all, I am very new to programming and I have recently started using python. I am interested in creating a file to essentially compare data points.

I am curious if it is possible to read specific lines from files and then write those lines to another file in separate columns (for comparative purposes)? If so could someone show me how I can alter my code to do this?

Below is the code that I am using and wish to alter. The files that I am interested in reading all begin with gauss_fit_ and end with .dat , however when I ran this program to read all these files ( instead of one) it did not work.

Thank You Very Much In Advance!

f=open("/home/flv1/histograms/gauss_fit_*.dat",'r')
f2=open("/home/flv1/test2.txt",'w')
for line in f:
f2.write(line)
f.close()
f2.close()
Reply With Quote
  #2  
Old 10-20-2008, 03:23 AM
tecktalk tecktalk is offline
Junior Member
 
Join Date: Sep 2008
Posts: 12 tecktalk is on a distinguished road
Default

Yes it would work.. but...you have to specify the RW permission for the file 2 in which you have to write the lines..

____________________
how to play aa beginners guide to poker
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 07:31 PM.


Powered by: vBulletin Version 3.0.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright 2004 - 2006 GrindingGears.com. All Rights Reserved.