Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Get True of false outside a loop
Post: RE: Get True of false outside a loop

I've got the solution, I changed some variable to true to false and my 2 variables are now declared outside the for : with fileinput.input(["result/"+fichier], inplace=1) as file_X : ...
morgandebray General Coding Help 2 2,450 Aug-09-2018, 12:39 PM
    Thread: Get True of false outside a loop
Post: Get True of false outside a loop

Hi, how can i get the value of each variable that i'm creating in my loop ? I have this : for fichier in os.listdir("result/"): if not fnmatch.fnmatch(fichier, 'file_0.txt'): #récupérati...
morgandebray General Coding Help 2 2,450 Aug-09-2018, 10:59 AM
    Thread: Split not working
Post: RE: Split not working

I've made some changes and it works (I forgot to make some adjustments before my loop...) @j.crater => original ligneTiers is Initial
morgandebray General Coding Help 3 3,111 Aug-09-2018, 09:34 AM
    Thread: Split not working
Post: Split not working

Hi, I want to know why my split is not wokring (the other splits are perfectly working : for ligneTiers in contenuTiers: ligneSplit = ligneTiers.split(';') sys.stderr.write(ligneSp...
morgandebray General Coding Help 3 3,111 Aug-09-2018, 09:02 AM
    Thread: Go to line starting with and variable not detected
Post: RE: Go to line starting with and variable not dete...

I found a temporary solution, I've made several with fileinput.input, so that my first is looping on /54/ and the second is looping on /22/
morgandebray General Coding Help 5 3,314 Aug-09-2018, 09:00 AM
    Thread: Go to line starting with and variable not detected
Post: RE: Go to line starting with and variable not dete...

the name used is new_name = 'DEFAULT_NAME'but i need the new_name to be the new_name from the if. I believe that because the "/54/" line is place after the "/22/" line, this could cause the issue, how...
morgandebray General Coding Help 5 3,314 Aug-09-2018, 07:08 AM
    Thread: Go to line starting with and variable not detected
Post: RE: Go to line starting with and variable not dete...

new_name is supposed to be used in the second condition (new_name can not be empty or null), but when I try to use new_name in the second condition, i have this NameError: name 'new_name' is not def...
morgandebray General Coding Help 5 3,314 Aug-08-2018, 03:05 PM
    Thread: Go to line starting with and variable not detected
Post: Go to line starting with and variable not detected

Hi, how can I go a line starting with a precise word ? After my first condition, I need to go to the line starting with "/22/" (I have to browse my file in different directions) and add new_name to th...
morgandebray General Coding Help 5 3,314 Aug-08-2018, 02:49 PM
    Thread: Adding a new line with content
Post: Adding a new line with content

Hello, I'm having a (little) issue by adding a new line. The newline is added before the line I want. See my code for fichier in os.listdir("result/"): if not fnmatch.fnmatch(fichier, 'file_0.tx...
morgandebray General Coding Help 1 1,847 Aug-08-2018, 02:25 PM
    Thread: Add a line after a specific line
Post: RE: Add a line after a specific line

This sounds complicated, no ? I have to insert line in different place in the same file, I would need to create like 4 files to add 4 lines ?
morgandebray General Coding Help 3 6,988 Aug-07-2018, 12:06 PM
    Thread: Add a line after a specific line
Post: Add a line after a specific line

Hi, I'm trying to add new line after a particular line. for line in file : if line.startswith('/22/'): #ADD LINE AFTER THIS line #WITH "TEST" AS CONTENTbut file.write("TEST...
morgandebray General Coding Help 3 6,988 Aug-07-2018, 10:56 AM
    Thread: "Split" file and comparison with CSV
Post: RE: "Split" file and comparison with CSV

Ok thanks, I think I got it. I'll come back if I have other problem !
morgandebray General Coding Help 14 6,327 Aug-07-2018, 10:22 AM
    Thread: "Split" file and comparison with CSV
Post: RE: "Split" file and comparison with CSV

Ok thanks, it's more clear. Do you think I can work with file for the moment and when it's over, change the code to do this ? With the files, I think it would be easier not to get lost for the momen...
morgandebray General Coding Help 14 6,327 Aug-07-2018, 10:11 AM
    Thread: "Split" file and comparison with CSV
Post: RE: "Split" file and comparison with CSV

Yes I did, I don't understand this part (I should have told, sorry) : for line in in_file: if block and line.strip() == '/##/': do_comparison(block=block) block = [] ...
morgandebray General Coding Help 14 6,327 Aug-07-2018, 10:04 AM
    Thread: "Split" file and comparison with CSV
Post: RE: "Split" file and comparison with CSV

Sorry I don't get it... Could you explain more please :/
morgandebray General Coding Help 14 6,327 Aug-07-2018, 09:56 AM
    Thread: "Split" file and comparison with CSV
Post: RE: "Split" file and comparison with CSV

I wanted to read block, but i don't know what to do, and what i found to create "block" was to create file
morgandebray General Coding Help 14 6,327 Aug-07-2018, 09:10 AM
    Thread: "Split" file and comparison with CSV
Post: RE: "Split" file and comparison with CSV

Create file is intermediate step, I didn't mean to create files but perhaps it's the best things to do ? Because the initial file could be big (I don't know how much), maybe the memory would be full ?...
morgandebray General Coding Help 14 6,327 Aug-07-2018, 08:52 AM
    Thread: "Split" file and comparison with CSV
Post: RE: "Split" file and comparison with CSV

Wow, thanks for the quality of the code and for the good reaction ! But I forgot to say, the files created needs to be group at the end to recreate a new big file. And the "/##/PARAM/XX/YY/ZZ/X/N/N/...
morgandebray General Coding Help 14 6,327 Aug-07-2018, 07:45 AM
    Thread: "Split" file and comparison with CSV
Post: "Split" file and comparison with CSV

Hi, I'm very new to python and I need your help guys. I want to know if it's possible to "split" file (with regex ?), read the line and make a comparison and then recreate the hole file. See this, ...
morgandebray General Coding Help 14 6,327 Aug-07-2018, 06:57 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020