Re: Understand workflow about reading and writing files in Python

2019-06-25 Thread DL Neil
On 25/06/19 11:50 AM, Windson Yang wrote: DL Neil > 于2019年6月24日周一 上午11:18写道: Yes, better to reply to list - others may 'jump in'... On 20/06/19 5:37 PM, Windson Yang wrote: > Thank you so much for you review DL Neil, it really helps :D. Howe

Re: Understand workflow about reading and writing files in Python

2019-06-24 Thread Windson Yang
DL Neil 于2019年6月24日周一 上午11:18写道: > Yes, better to reply to list - others may 'jump in'... > > > On 20/06/19 5:37 PM, Windson Yang wrote: > > Thank you so much for you review DL Neil, it really helps :D. However, > > there are some parts still confused me, I replyed as below. > > It's not a partic

Re: Understand workflow about reading and writing files in Python

2019-06-24 Thread Windson Yang
When you said "C-runtime buffered I/O", are you talking about Standard I/O in C (FILE * object)? AFAIN, In CPython, we didn't use Standard I/O, right? Dennis Lee Bieber 于2019年6月25日周二 上午12:48写道: > On Mon, 24 Jun 2019 15:18:26 +1200, DL Neil > declaimed the following: > > > > > >However, the OpSy

Re: Understand workflow about reading and writing files in Python

2019-06-23 Thread DL Neil
Yes, better to reply to list - others may 'jump in'... On 20/06/19 5:37 PM, Windson Yang wrote: Thank you so much for you review DL Neil, it really helps :D. However, there are some parts still confused me, I replyed as below. It's not a particularly easy topic... DL Neil

Fwd: Understand workflow about reading and writing files in Python

2019-06-23 Thread Windson Yang
Thank you so much for you review DL Neil, it really helps :D. However, there are some parts still confused me, I replyed as below. DL Neil 于2019年6月19日周三 下午2:03写道: > I've not gone 'back' to refer to any ComSc theory on buffer-management. > Perhaps you might benefit from such? > > I just take a cr

Re: Understand workflow about reading and writing files in Python

2019-06-18 Thread DL Neil
I've not gone 'back' to refer to any ComSc theory on buffer-management. Perhaps you might benefit from such? I like your use of the word "shift", so I'll continue to use it. There are three separate units of data to consider - each of which could be called a "buffer". To avoid confusing (mysel

Understand workflow about reading and writing files in Python

2019-06-18 Thread Windson Yang
I'm trying to understand the workflow of how Python read/writes data with buffer. I will be appreciated if someone can review it. ### Read n data 1. If the data already in the buffer, return data 2. If the data not in the buffer: 1. copy all the current data from the buffer 2. create a new

Re: Understand workflow about reading and writing files in Python

2019-06-17 Thread Terry Reedy
On 6/15/2019 12:52 AM, Windson Yang wrote: I'm trying to understand the workflow of how python read/writes files with buffer. I drew a diagram for it. I will be appreciated if someone can review the diagram :D [image: 屏幕快照 2019-06-15 下午12.50.57.png] Text only list, no attachments. -- Terry Ja

Understand workflow about reading and writing files in Python

2019-06-17 Thread Windson Yang
I'm trying to understand the workflow of how python read/writes files with buffer. I drew a diagram for it. I will be appreciated if someone can review the diagram :D [image: 屏幕快照 2019-06-15 下午12.50.57.png] -- https://mail.python.org/mailman/listinfo/python-list

Re: Precision reading and writing data frames to csv

2017-03-11 Thread Paulo da Silva
Às 23:29 de 11-03-2017, Erik escreveu: > Hi Paulo, > > On 11/03/17 22:01, Paulo da Silva wrote: ... >> Now my question is: Is it possible the occurrence of successive >> cumulative errors? I mean reading a file, adding lines or change few >> ones but keeping the most of the other lines untouched

Re: Precision reading and writing data frames to csv

2017-03-11 Thread Erik
Hi Paulo, On 11/03/17 22:01, Paulo da Silva wrote: I have a dir with lots of csv files. These files are updated +- once a day. I could see that some values are converted, during output, to very close values but with lots of digits. I understand that is caused by the internal bits' representation

Re: Precision reading and writing data frames to csv

2017-03-11 Thread MRAB
On 2017-03-11 22:01, Paulo da Silva wrote: Hi! I have a dir with lots of csv files. These files are updated +- once a day. I could see that some values are converted, during output, to very close values but with lots of digits. I understand that is caused by the internal bits' representation of

Precision reading and writing data frames to csv

2017-03-11 Thread Paulo da Silva
Hi! I have a dir with lots of csv files. These files are updated +- once a day. I could see that some values are converted, during output, to very close values but with lots of digits. I understand that is caused by the internal bits' representation of the float/double values. Now my question is:

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread Luca Menegotto
Il 03/09/2015 17:05, kbtyo ha scritto: I am experimenting with many exception handling and utilizing > continue vs pass. After pouring over a lot of material on SO > and other forums I am still unclear as to the difference when > setting variables and applying functions within multiple "for" >

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread kbtyo
On Thursday, September 3, 2015 at 12:12:04 PM UTC-4, Chris Angelico wrote: > On Fri, Sep 4, 2015 at 1:57 AM, kbtyo wrote: > > I have used CSV and collections. For some reason when I apply this > > algorithm, all of my files are not added (the output is ridiculously small > > considering how much

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread Chris Angelico
On Fri, Sep 4, 2015 at 1:57 AM, kbtyo wrote: > I have used CSV and collections. For some reason when I apply this algorithm, > all of my files are not added (the output is ridiculously small considering > how much goes in - think KB output vs MB input): > > from glob import iglob > import csv >

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread Terry Reedy
On 9/3/2015 11:05 AM, kbtyo wrote: I am experimenting with many exception handling and utilizing continue vs pass. 'pass' is a do-nothing place holder. 'continue' and 'break' are jump statements [snip] However, I am uncertain as to how this executes in a context like this: import glob i

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread kbtyo
On Thursday, September 3, 2015 at 11:52:16 AM UTC-4, Chris Angelico wrote: > On Fri, Sep 4, 2015 at 1:38 AM, kbtyo wrote: > > Thank you for the elaboration. So, what I hear you saying is that (citing, > > "In this case, there's no further body, so it's going to be the same as > > "pass" (which >

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread Chris Angelico
On Fri, Sep 4, 2015 at 1:38 AM, kbtyo wrote: > Thank you for the elaboration. So, what I hear you saying is that (citing, > "In this case, there's no further body, so it's going to be the same as > "pass" (which > means "do nothing")") that the else block is not entered. For exma Seems like a c

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread kbtyo
On Thursday, September 3, 2015 at 11:27:58 AM UTC-4, Chris Angelico wrote: > On Fri, Sep 4, 2015 at 1:05 AM, kbtyo wrote: > > However, I am uncertain as to how this executes in a context like this: > > > > import glob > > import csv > > from collections import OrderedDict > > > > interesting_files

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread kbtyo
On Thursday, September 3, 2015 at 11:27:58 AM UTC-4, Chris Angelico wrote: > On Fri, Sep 4, 2015 at 1:05 AM, kbtyo wrote: > > However, I am uncertain as to how this executes in a context like this: > > > > import glob > > import csv > > from collections import OrderedDict > > > > interesting_files

Re: continue vs. pass in this IO reading and writing

2015-09-03 Thread Chris Angelico
On Fri, Sep 4, 2015 at 1:05 AM, kbtyo wrote: > However, I am uncertain as to how this executes in a context like this: > > import glob > import csv > from collections import OrderedDict > > interesting_files = glob.glob("*.csv") > > header_saved = False > with open('merged_output_mod.csv','w') as

continue vs. pass in this IO reading and writing

2015-09-03 Thread kbtyo
Good Morning: I am experimenting with many exception handling and utilizing continue vs pass. After pouring over a lot of material on SO and other forums I am still unclear as to the difference when setting variables and applying functions within multiple "for" loops. Specifically, I understa

Re: Python reading and writing

2014-06-27 Thread aws Al-Aisafa
Thanks man. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python reading and writing

2014-06-27 Thread Peter Otten
aws Al-Aisafa wrote: > Why doesn't this code work? > #I want this code to write to the first file and then take the > #contents of the first file and copy them to the second. > > from sys import argv > > script, file1, file2 = argv > > > def write_to_file(fileread, filewrite): > '''Wr

Python reading and writing

2014-06-27 Thread aws Al-Aisafa
Why doesn't this code work? http://pastebin.com/A3Sf9WPu -- https://mail.python.org/mailman/listinfo/python-list

Re: Error in reading and writing CSV format file in python

2013-02-11 Thread inshu chauhan
On Mon, Feb 11, 2013 at 3:22 PM, Dave Angel wrote: > On 02/11/2013 06:00 AM, inshu chauhan wrote: > >> In the programme below I am trying to read two csv format files and >> process >> them and write a new file with some of theirs data. >> >> import csv >> f1_reader = csv.reader(open(r"Z:\Weka >>

Re: Error in reading and writing CSV format file in python

2013-02-11 Thread Dave Angel
On 02/11/2013 06:00 AM, inshu chauhan wrote: In the programme below I am trying to read two csv format files and process them and write a new file with some of theirs data. import csv f1_reader = csv.reader(open(r"Z:\Weka work\Feature_Vectors_Fullset_00.arff")) f2_reader = csv.reader(open(r"Z:\W

Re: Error in reading and writing CSV format file in python

2013-02-11 Thread inshu chauhan
On Mon, Feb 11, 2013 at 2:02 PM, MRAB wrote: > On 2013-02-11 12:44, inshu chauhan wrote: > >> >> On Mon, Feb 11, 2013 at 1:26 PM, Steven D'Aprano >> >> > >> wrote: >> >> inshu chauhan wrote: >> >> > In the programme below I am trying to rea

Re: Error in reading and writing CSV format file in python

2013-02-11 Thread MRAB
On 2013-02-11 12:44, inshu chauhan wrote: On Mon, Feb 11, 2013 at 1:26 PM, Steven D'Aprano mailto:steve+comp.lang.pyt...@pearwood.info>> wrote: inshu chauhan wrote: > In the programme below I am trying to read two csv format files and > process them and write a new file with some

Re: Error in reading and writing CSV format file in python

2013-02-11 Thread inshu chauhan
On Mon, Feb 11, 2013 at 1:26 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > inshu chauhan wrote: > > > In the programme below I am trying to read two csv format files and > > process them and write a new file with some of theirs data. > > > > import csv > > f1_reader = csv.re

Re: Error in reading and writing CSV format file in python

2013-02-11 Thread Steven D'Aprano
inshu chauhan wrote: > In the programme below I am trying to read two csv format files and > process them and write a new file with some of theirs data. > > import csv > f1_reader = csv.reader(open(r"Z:\Weka > work\Feature_Vectors_Fullset_00.arff")) > f2_reader = csv.reader(open(r"Z:\Weka > work\

Re: Error in reading and writing CSV format file in python

2013-02-11 Thread MRAB
On 2013-02-11 11:00, inshu chauhan wrote: In the programme below I am trying to read two csv format files and process them and write a new file with some of theirs data. import csv f1_reader = csv.reader(open(r"Z:\Weka work\Feature_Vectors_Fullset_00.arff")) f2_reader = csv.reader(open(r"Z:\Weka

Error in reading and writing CSV format file in python

2013-02-11 Thread inshu chauhan
In the programme below I am trying to read two csv format files and process them and write a new file with some of theirs data. import csv f1_reader = csv.reader(open(r"Z:\Weka work\Feature_Vectors_Fullset_00.arff")) f2_reader = csv.reader(open(r"Z:\Weka work\Feature_Vectors_Fullset_00_noxy+class.

Re: Reading and writing to a file creates null characters

2012-01-13 Thread Denhua
On Jan 12, 6:21 pm, MRAB wrote: > On 12/01/2012 22:26, Denhua wrote: > > > > > > > > > Hi, > > > I've got a file which I'd like to read, modify and write. > > > # file contents > > a > > b > > c > > d > > > My script reads the file contents into a list and rotates the list and > > writes it back t

Re: Reading and writing to a file creates null characters

2012-01-12 Thread MRAB
On 12/01/2012 22:26, Denhua wrote: Hi, I've got a file which I'd like to read, modify and write. # file contents a b c d My script reads the file contents into a list and rotates the list and writes it back to the same file. Problem is that the output contains null characters. I don't know whe

Re: Reading and writing to a file creates null characters

2012-01-12 Thread Roy Smith
In article <4f7d125a-2713-4b57-a108-2a56ae653...@h3g2000yqe.googlegroups.com>, Denhua wrote: > [omitted] > f.write("\n".join(newlist)) > f.close() > > # output > > [root@Inferno html]# python rotate.py > ['b', 'c', 'd', 'a'] > [root@Inferno html]# python rotate.py > ['c', 'd', 'a', '\x00\x00\

Reading and writing to a file creates null characters

2012-01-12 Thread Denhua
Hi, I've got a file which I'd like to read, modify and write. # file contents a b c d My script reads the file contents into a list and rotates the list and writes it back to the same file. Problem is that the output contains null characters. I don't know where they are coming from. #!/usr/bin/

Re: reading and writing files

2011-08-23 Thread Chris Rebert
On Tue, Aug 23, 2011 at 11:29 PM, Muresan Alexandru Mihai wrote: > If you need an int isn't better to use input() instead of raw_input() ? Absolutely not! input() does an eval(), which is very dangerous security-wise and can also lead to rather strange behavior. input() is so bad that it was remo

Re: reading and writing files

2011-08-23 Thread Muresan Alexandru Mihai
If you need an int isn't better to use input() instead of raw_input() ? On Tue, Aug 23, 2011 at 10:00 PM, Adrián Monkas wrote: > Hi. > I`ve been trying to copy a long text from one file to another but it always > copied me just a small part. > I would be glad if you can help me or explain which i

Re: reading and writing files

2011-08-23 Thread Chris Rebert
On Tue, Aug 23, 2011 at 9:05 PM, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Adrián Monkas wrote: >>             print "Abro Archivo Origen" >>             archivo=open("D:\Boot.txt","r") > Your filenames are incorrect, since you use the backslash without escaping > it.  So the source file ha

Re: reading and writing files

2011-08-23 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Adrián Monkas wrote: Hi. I`ve been trying to copy a long text from one file to another but it always copied me just a small part. I would be glad if you can help me or explain which is my error. Thanks ---

reading and writing files

2011-08-23 Thread Adrián Monkas
Hi. I`ve been trying to copy a long text from one file to another but it always copied me just a small part. I would be glad if you can help me or explain which is my error. Thanks -- def runMenu(): print "\nMENU"

Re: ANN: pdfrw pure-Python PDF file reading and writing

2009-11-28 Thread Patrick Maupin
On Nov 27, 2:35 am, Patrick Maupin wrote: > pdfrw is a basic PDF file manipulation library, developed and tested > on Python 2.5 and 2.6. > > pdfrw can read and write PDF files, and can also be used to read in > PDFs which can then be used inside reportlab (as source material for > new PDFs).  Thi

Re: ANN: pdfrw pure-Python PDF file reading and writing

2009-11-27 Thread Patrick Maupin
On Nov 27, 2:35 am, Patrick Maupin wrote: > pdfrw is a basic PDF file manipulation library, developed and tested > on Python 2.5 and 2.6. > > pdfrw can read and write PDF files, and can also be used to read in > PDFs which can then be used inside reportlab (as source material for > new PDFs).  Thi

ANN: pdfrw pure-Python PDF file reading and writing

2009-11-27 Thread Patrick Maupin
pdfrw is a basic PDF file manipulation library, developed and tested on Python 2.5 and 2.6. pdfrw can read and write PDF files, and can also be used to read in PDFs which can then be used inside reportlab (as source material for new PDFs). This is also the underlying library for a new rst2pdf ext

Re: Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread Ken Starks
Gilly wrote: Hi I am trying to create an application that uses some form of input to create a midi file. I would like for this to be a 'real time' process. In other words, I want to be able to begin playing the midi file before I finish writing it, and continue writing as it plays. I would reall

Re: Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread Chuckk Hubbard
Threading was recommended to me as a way to time things: http://docs.python.org/lib/timer-objects.html Dunno if that helps you. -Chuckk On Sun, May 4, 2008 at 8:11 PM, Gilly <[EMAIL PROTECTED]> wrote: > Hi > I am trying to create an application that uses some form of input to > create a midi fil

Re: Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread Max M
Gilly skrev: Hi I am trying to create an application that uses some form of input to create a midi file. I would like for this to be a 'real time' process. In other words, I want to be able to begin playing the midi file before I finish writing it, and continue writing as it plays. Perhaps cso

Re: Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread Diez B. Roggisch
Gilly schrieb: On May 4, 9:14 pm, David <[EMAIL PROTECTED]> wrote: On Sun, May 4, 2008 at 7:11 PM, Gilly <[EMAIL PROTECTED]> wrote: Hi I am trying to create an application that uses some form of input to create a midi file. I would like for this to be a 'real time' process. In other words, I

Re: Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread Gilly
On May 4, 9:14 pm, David <[EMAIL PROTECTED]> wrote: > On Sun, May 4, 2008 at 7:11 PM, Gilly <[EMAIL PROTECTED]> wrote: > > Hi > > I am trying to create an application that uses some form of input to > > create a midi file. > > I would like for this to be a 'real time' process. In other words, I

Re: Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread David
On Sun, May 4, 2008 at 7:11 PM, Gilly <[EMAIL PROTECTED]> wrote: > Hi > I am trying to create an application that uses some form of input to > create a midi file. > I would like for this to be a 'real time' process. In other words, I > want to be able to begin playing the midi file before I fin

Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread Gilly
Hi I am trying to create an application that uses some form of input to create a midi file. I would like for this to be a 'real time' process. In other words, I want to be able to begin playing the midi file before I finish writing it, and continue writing as it plays. I would really appreciate an

Issue with reading and writing into .ini files using python

2007-11-21 Thread tarun
Hello, I am using config approach as mentioned in the below link to read and write into setup (.ini) files: http://www.voidspace.org.uk/python/configobj.html I've a key named 'SELECTED' in my .ini file. Sometimes I get the following error on trying to read the .ini file:val = dict.__getitem_

Re: Reading (and writing?) audio file tags

2007-05-25 Thread Jarek Zgoda
Paul Moore napisał(a): >> Anyway, what you want is Mutagen. It handles both Flac and Mp3 tags, as well >> as many others:http://www.sacredchao.net/quodlibet/wiki/Development/Mutagen > > Excellent! The web page you mentioned gave "access denied", but I got > to it via Google's cache, and the downl

Re: Reading (and writing?) audio file tags

2007-05-24 Thread Paul Moore
On 24 May, 17:22, darren kirby <[EMAIL PROTECTED]> wrote: > quoth the Paul Moore: > > > I'd like to write some scripts to analyze and manipulate my music > > files. The files themselves are in MP3 and FLAC format (mostly MP3, > > but FLAC where I ripped original CDs and wanted a lossless format). >

Re: Reading (and writing?) audio file tags

2007-05-24 Thread darren kirby
quoth the Paul Moore: > I'd like to write some scripts to analyze and manipulate my music > files. The files themselves are in MP3 and FLAC format (mostly MP3, > but FLAC where I ripped original CDs and wanted a lossless format). > I've no idea what form of tags are used in the files (ID3v1, ID3v2,

Reading (and writing?) audio file tags

2007-05-24 Thread Paul Moore
I'd like to write some scripts to analyze and manipulate my music files. The files themselves are in MP3 and FLAC format (mostly MP3, but FLAC where I ripped original CDs and wanted a lossless format). I've no idea what form of tags are used in the files (ID3v1, ID3v2, OGG, APE, ...) I just used wh

RE: simultaneous reading and writing a textfile

2006-05-17 Thread Peter Otten
Mark Wilkinson wrote: > Why this: > >> lines = iter(infile.readline, "") >> # copy one line at a time >> for line in lines: > > Rather than this? > >> for line in infile: file.next() uses an internal cache. The data in that cache would be lost when the rest of the file is copied using file.rea

RE: simultaneous reading and writing a textfile

2006-05-17 Thread Mark Wilkinson
Why this: > lines = iter(infile.readline, "") > # copy one line at a time > for line in lines: Rather than this? > for line in infile: ..Mark This email and any attachment may contain confidential, privileged information for the sole use of the intended recipient. If you are not the intended

Re: simultaneous reading and writing a textfile

2006-05-17 Thread Marco Herrn
On 2006-05-16, Peter Otten <[EMAIL PROTECTED]> wrote: >> Now how can I achieve, what I want? Really exchange one line with >> another, regardless of their length. Is this possible? If this is not >> possible, then what would be the best approach to do this? > > A file is exposed as a sequence of by

Re: simultaneous reading and writing a textfile

2006-05-16 Thread Peter Otten
Marco Herrn wrote: > I have a text file with some lines in it. > Now I want to iterate over this file and exchange some lines with some > others. I tried this approach: > This should inspect the file and find the first line, that can't be > split into two parts (that means, which has only one wor

Re: simultaneous reading and writing a textfile

2006-05-16 Thread Larry Bates
Marco Herrn wrote: > Hi, > > I have a text file with some lines in it. > Now I want to iterate over this file and exchange some lines with some > others. I tried this approach: > > try: > myfile= file('myfile', 'r+') > > while 1: > line= myfile.readline() >

simultaneous reading and writing a textfile

2006-05-16 Thread Marco Herrn
Hi, I have a text file with some lines in it. Now I want to iterate over this file and exchange some lines with some others. I tried this approach: try: myfile= file('myfile', 'r+') while 1: line= myfile.readline() if not line: break l= li

Re: Reading and Writing

2004-12-24 Thread Mike Meyer
Sir Galahad the chaste <[EMAIL PROTECTED]> writes: > Hi, > > [EMAIL PROTECTED] wrote: >> How should I: Open a Text file, read from it, modify it, print to >> another .txt? >> For instance: Read a string, sort it, write the sorted string. > > What do you mean by "sorting"? If you want to sort the l

Re: Reading and Writing

2004-12-23 Thread Novitiate
-Galahad, Thank you very much. I will give it a shot and see if I can make it hapen. I think this will help a lot. I was just trying to implement a simple sorting algorithm that I knew from C++, for practice but I couldn't figure the mechanics of Python. Thanks again, Novitiate -- http://mai

Re: Reading and Writing

2004-12-23 Thread Novitiate
-Galahad, Thank you very much. I will give it a shot and see if I can make it hapen. I think this will help a lot. I was just trying to implement a simple sorting algorithm that I knew from C++, for practice but I couldn't figure the mechanics of Python. Thanks again, Novitiate -- http://mai

Re: Reading and Writing

2004-12-23 Thread Sir Galahad the chaste
Hi, [EMAIL PROTECTED] wrote: How should I: Open a Text file, read from it, modify it, print to another .txt? For instance: Read a string, sort it, write the sorted string. What do you mean by "sorting"? If you want to sort the lines contained in a file, you could do something like this. $ cat in.

Reading and Writing

2004-12-23 Thread elias . goodman
I am new to Python and programming. I am looking for some basic instruction here. How should I: Open a Text file, read from it, modify it, print to another .txt? For instance: Read a string, sort it, write the sorted string. I understand the algorithms but I don't know the actual mechanics of P