Different ways of reading a file
Be it any platform or any mobile programming language, the file manipulation is a very important aspect of it. So this article is dedicated to different types of reading from an file in PyS60.
f = open("c://file_read.txt","rb")
this directs a file to open in a read mode you can also open in write and append mode.
f.tell()
tell function tells you about your current position
f.seek(56,0)
seek function displaces your position and reads from a position as specified. The first parameter in the function is the position and the second is the relative displacement it can take three values 0 means move to the absolute position counting from the start of the line.
1 means move to the absolute position counting from the current position.
and finally 2 means move the absolute position starting from the end of file.
in our case the file will read from position 56 starting from start of the line.
f.readline()
readline function will read the entire line we can also pass the parameters in the readline function.
Thank you for reading this post. You can now Leave A Comment (0) or Leave A Trackback.
Post Info
This entry was posted on Wednesday, July 2nd, 2008 and is filed under Blogroll.You can follow any responses to this entry through the Comments Feed. You can Leave A Comment, or A Trackback.
Previous Post: Groups seek drilling halt near sage grouse habitat »
Next Post: Google wins source code ruling against Viacom »
- Would-be Japanese space tourist wants $21M back
- NASA scales back flagship Mars mission
- Bulgarian archaeologists unearth ancient chariot
- Witnesses: Large meteor streaks across Canada sky
- Solar panels on graves give power to Spanish town
- Fuel from food? The feast is over
- Fabulous flippers: Dolphins have quite the kick
- Whales rescued from Australian beach join pod
- Siberian quake triggers false US seismic reports
- Pirates sign Indian _ not Cleveland _ pitchers

