Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8977639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:25:04+00:00 2026-06-15T19:25:04+00:00

My For loop skips the first line each time I read one line at

  • 0

My For loop skips the first line each time I read one line at a time.
The problem doesn’t occur when I just need to read in the entire file into memory, but mostly I need to read in one line a at a time.

Here’s one example where the problem occurs.
This loop just reorders the elements in a list.
I’ve omitted the lines where I open and close read & write files (the clunky way I do it). Its all comma delimited text data.

lineString=fileItemR.readline()

for lineString in fileItemR:
    lineList = lineString.split(",")
    newList = (lineList[1],lineList[0],lineList[2:99])
    lineItem = str(newList)
    formatString = lineItem.replace("('","").replace("', '",",").replace("', ",",").replace("['","").replace("\\n","\n").replace("'])","")

    fileItemW.write(formatString)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:25:05+00:00Added an answer on June 15, 2026 at 7:25 pm

    It’s the first readline() (the one you call before the loop) that eats your first line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

# Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize) File /Users/maninder/git/TrialScheduler/TrialScheduler/main.py, line 27, in Loop Loop(Classroom1,
I read in a csv file by using a while loop: while (($data =
Is there an elegant way of skipping first line of file when using python
The following code skips the first second of audio in a pcm caf file
I basically need something inside a foreach loop that will skip over the first
When the while loop iterates, it skips both if loops and when the q=q->next
Is there a token in java that skips the rest of the for loop?
The loop for root, dir, file in os.walk(startdir) works through these steps? for root
I have a read file method that reads the date from the start of
I have a problem reading every line to count the regex of <a href=

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.