Python Forum
[split] Splitting a string into six pieces
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Splitting a string into six pieces
#2
Does your file have any blank lines in it? That could cause the problem. You can be preemptive about it with a conditional:

for dataStr in dataFile:
    if dataStr.strip():
        (d1,d2,d3,d4,d5,d6)=dataStr.split()#split data into six parts.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: [split] Splitting a string into six pieces - by ichabod801 - Dec-25-2018, 06:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split string into 160-character chunks while adding text to each part iambobbiekings 9 9,949 Jan-27-2021, 08:15 AM
Last Post: iambobbiekings
  Split String lekuru01 6 3,737 Mar-19-2019, 10:42 AM
Last Post: lekuru01
  Using a function: splitting, joining, and slicing a string Drone4four 2 4,989 Dec-27-2018, 07:52 AM
Last Post: perfringo
  Quickest way of splitting a string yanhto 1 2,551 May-01-2018, 12:24 PM
Last Post: snippsat
  How to access each line in for loop and split string SriRajesh 2 3,258 Aug-14-2017, 06:05 PM
Last Post: tetrmnot
  [split] deleting pieces of strings viking_helgi 2 3,554 Feb-04-2017, 02:15 PM
Last Post: Ofnuts
  Splitting A String In Python Saif133 6 6,640 Jan-14-2017, 04:09 AM
Last Post: Saif133

Forum Jump:

User Panel Messages

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