|
by: wordsender |
last post by:
Hey guys,
I can't figure this one out, why is this simple script giving me
problems?
logfile=file(r'test.txt','w')
logfile.write('datetime')
test=logfile.readlines()
When I run it I get the error message:
|
by: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
# to open a file and write to file
# do
f=open('xfile.txt','w')
# this creates a file "object" and name it f.
# the second argument of open can be
|
by: John Reese |
last post by:
def uselessHash(filename):
fp= open(filename)
hash= 0
for line in fp:
hash ^= hash(line.strip())
fp.close() # do I need this or is fp closed by ref count?
return hash
Consider the function above. Do I need the fp.close(), or will the
file be closed automatically when fp goes out of scope and its
|
by: nephish |
last post by:
Hey there.
i want to set a variable to represent the last line of a text file
how do i do that?
or even better, how do i create a list of the lines of a text file?
|
by: Ross Reyes |
last post by:
HI -
Sorry for maybe a too simple a question but I googled and also checked my
reference O'Reilly Learning Python
book and I did not find a satisfactory answer.
When I use readlines, what happens if the number of lines is huge? I have
a very big file (4GB) I want to
read in, but I'm sure there must be some limitation to readlines and I'd
like to know how it is handled by python.
I am using it like this:
|
|
by: bradfordh |
last post by:
Hello everyone.
I am not sure how hard of a question is, but I do know that I need some
help if you can give it. What I want to do is read the lines in a text
file and store each line into a variable. I believe that I can use
readlines() to read the individual lines, but how would I store each
line into a variable for further analysis? Thanks for any and all
suggestions.
|
by: bahoo |
last post by:
Hi,
I have a text file containing a single line of text, such as
0024
How should I read it into a "list"?
I tried this, but the "join" did not work as expected. Any
suggestions?
|
by: planetmatt |
last post by:
I am a Python beginner. I am trying to loop through a CSV file which
I can do. What I want to change though is for the loop to start at
row 2 in the file thus excluding column headers.
At present I am using this statement to initiate a loop though the
records:
for line in f.readlines():
How do I start this at row 2?
|
by: Shankarjee Krishnamoorthi |
last post by:
Hi,
I am new to Python. I am trying to do the following
inp = open(my_file,'r')
for line in inp:
# Perform some operations with line
if condition something:
# Start re reading for that position again
for line in inp:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|