LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-27-2003, 02:53 PM   #1
Heybaby
LQ Newbie
 
Registered: Oct 2003
Posts: 1

Rep: Reputation: 0
Python


Hey.
I am just starting out with Python. I know my question is trivial, and its almost def. in the manual, I just can't seem to find it.
Couls someone pretty pretty please tell me the code to read a file and copy certain data entries from the file into a numerical array. what could do i use to find a certain word/string in the text file?
 
Old 10-28-2003, 05:04 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,751

Rep: Reputation: 271Reputation: 271Reputation: 271
Sorry, I gave an incorrect answer.

---------------------
Steve Stites

Last edited by jailbait; 10-28-2003 at 05:06 PM.
 
Old 10-28-2003, 05:22 PM   #3
contrasutra
LQ Guru
 
Registered: Mar 2003
Location: New Jersey
Distribution: Arch Linux
Posts: 1,445

Rep: Reputation: 46
For processing strings, look at the "re" (regular expressions) module,

to open a file:

x = open('/file/path', 'r')

to read a file and create a list of its Lines:

x = x.readlines()

to copy that text into a new file:

y = open('/path/to/newfile', 'w')

y.writelines(x)

y.flush()
y.close()
x.close()
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 08:02 PM
installing python library's (Python Numeric) Four Linux - Newbie 1 10-16-2005 03:31 PM
Python guru's - Is this a python bug? or is it me? bardinjw Programming 2 06-23-2005 09:17 AM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 01:11 PM
install python 2.3 ,necssary to remove python 2.2 ngan_yine Linux - Newbie 7 12-28-2003 05:07 PM


All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration