std in and stdout

2006-07-10 Thread Juergen Huber
hello,

i have a question!

how would i fix the following problem:

now i have an input file with a fix name and an output file!
i have this two files hardcoded written in the sourcecode of this function!

in the future i will start this script with the command line.
the syntax should be look like this:

Python Function | Source File|   Output File
---
fileanalyse.pysourcefile.csv filenalyse.txt

i will call the programm always with the commandline, that i could type in
various filenames for the input and output files!

could anybody help me?!

-- 
http://mail.python.org/mailman/listinfo/python-list


delete first line in a file

2006-06-30 Thread Juergen Huber
hello,

i am a dummy user in python and new in this programming language and so
there will be questions, that´s for you no problem! i never have before
programmed in any language! sorry for this! i hope you will help me, that i
also could the basics in this language! and later many more, so i hope ! :)

the first question for me in this newsgroup will be the follow one:

- is there a way to delete in a csv-file the first line?!

big thanks, juergen

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delete first line in a file

2006-06-30 Thread Juergen Huber
Fredrik Lundh wrote:
 Juergen Huber wrote:

 i am a dummy user in python and new in this programming language and
 so there will be questions, that´s for you no problem! i never have
 before programmed in any language! sorry for this! i hope you will
 help me, that i also could the basics in this language! and later
 many more, so i hope ! :)

 the first question for me in this newsgroup will be the follow one:

 - is there a way to delete in a csv-file the first line?!

 in general, modern file systems can only remove and add stuff at the
 end of a
 file, so the only way to do this is to rewrite the entire file.

 (you can either load the entire file, fix it up, and write it out
 again, or copy the file to a new file, skipping the first line or
 row).

 /F

ok...i thought as much, that i have to copy this file!

how will i do that?!
how will i fix this file = delete the first line?!

with which commands could i do that?!

thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delete first line in a file

2006-06-30 Thread Juergen Huber
Fredrik Lundh wrote:
 Juergen Huber wrote:

 ok...i thought as much, that i have to copy this file!

 how will i do that?!
 how will i fix this file = delete the first line?!

 with which commands could i do that?!

 start here:

 http://docs.python.org/tut/node9.html#SECTION00920

 /F

that documentation i have already read, but it wouldn`t help me for my
problem!
i know, how i can read the first line an print them on the screen!
but...how can i say python, delete the first line?!
thats my problem!
in the entry of my posting i wrote, that i am a newbie and so please
understand me, that i ask so questions?! :-)

thanks for your help!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delete first line in a file

2006-06-30 Thread Juergen Huber
this helps me!

thank you very much!

greetings, juergen



JH Fredrik Lundh wrote:

 Juergen Huber wrote:



 ok...i thought as much, that i have to copy this file!



 how will i do that?!

 how will i fix this file = delete the first line?!



 with which commands could i do that?!



 start here:



 http://docs.python.org/tut/node9.html#SECTION00920



 /F

JH that documentation i have already read, but it wouldn`t help me for my

JH problem!

JH i know, how i can read the first line an print them on the screen!

JH but...how can i say python, delete the first line?!

JH thats my problem!

as Fredrik told you, you can not delete the first line directly!!!

JH in the entry of my posting i wrote, that i am a newbie and so please

JH understand me, that i ask so questions?! :-)

We are trying to understand that, but it is expected some effort on

your side as well :)

You didn't read the documentation properly!

try to experiment with the code by yourself as well!

Try:

1) open your file

2) use readlines() method

which returns the list of ALL rows from the file and store them to some
variable.

it can be done for example like:

all_lines = f.readlines()

(if you do not know, what the list is, start here:

http://docs.python.org/tut/node5.html#SECTION00514)

4) save the list members without its first member to the file

for example:

for line in all_lines[1:]:

f.write(line)

5) close the file



Good luck

Petr Jakes











JH thanks for your help!



-- 
http://mail.python.org/mailman/listinfo/python-list


print shell output in a file

2006-06-30 Thread Juergen Huber
hello,

one more question i will have!

now i have written a little programm, which delivers me an output on the
shell!


here is the print command, which delivers me the following output (see
below) on the shell:


 print '%-30s | %-12d | %-12d |%-12d ' % (typename,
  size / count,
  count,
  size)



--NAME-|Groesse(Byte)-|Anzahl|-Gesamtgroesse
(Byte)-|

--
ADD_REAL_N6| 4| 1|4
AND_BOOL_N10   | 4| 1|4
AND_BOOL_N12   | 4| 1|4



Is there a way to put this output in an file?!?! i searched about 2h for
this, but i couldn`t find an answer!

thnks, juergen

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print shell output in a file

2006-06-30 Thread Juergen Huber
hello,

if i would type in your code, i became the following output in the
output.txt - file


BOOL   | 4 | 50463|201852


but why?!
he wouldn´t do that for all the entrys in the csv file! but only for the
first one in the file!




Stephan Wassipaul wrote:
 f = file('output.txt','w')
 print f, '%-30s | %-12d | %-12d |%-12d ' % (typename,
size / count,
count,
size)
 f.close()
 hello,

 one more question i will have!

 now i have written a little programm, which delivers me an output on
 the shell!


 here is the print command, which delivers me the following output
 (see below) on the shell:


  print '%-30s | %-12d | %-12d |%-12d ' % (typename,
   size / count,
   count,
   size)



 --NAME-|Groesse(Byte)-|Anzahl|-Gesamtgroe
sse
 (Byte)-|
 -
---
 --
 ADD_REAL_N6| 4| 1|4
 AND_BOOL_N10   | 4| 1|4
 AND_BOOL_N12   | 4| 1|4



 Is there a way to put this output in an file?!?! i searched about 2h
 for this, but i couldn`t find an answer!

 thnks, juergen

-- 
http://mail.python.org/mailman/listinfo/python-list