Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split not working
#1
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(ligneSplit[0])
Initial = 78717;26410009000010;0;0;1
Expected = 78717
Result = 7871726410009000010001
Reply
#2
Could you add a print to see what the original line (ligneTiers) is?
Modified code for test gives me:
Initial = "78717;26410009000010;0;0;1" 
ligneSplit = Initial.split(';')
ligneSplit
['78717', '26410009000010', '0', '0', '1']
ligneSplit[0]
'78717'
Reply
#3
Hi,

Try the following:

import sys
contenuTiers = '78717;26410009000010;0;0;1'
sys.stderr.write(contenuTiers.split(';')[0])
Reply
#4
I've made some changes and it works (I forgot to make some adjustments before my loop...)

@j.crater => original ligneTiers is Initial
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Script has stopped working santhosh 1 3,189 Feb-27-2017, 03:21 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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