We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,708 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Some tricky file writing, and string question.

So, I have a two part question for you...

I'm going to be writing several lines of code to a .txt file, but I won't know what each line is, or how many there will be. There could easily be hundreds of lines. I need to add a prefix to the front of each individual line. Is such a thing possible, when you don't know how many lines there are going to be? (It will all be contained within a list before being written to the file, btw.)

And second question... if I potentially had say, over 1000 lines of text, would the list be able to hold them all? I haven't seen any mention of lists' limitations anywhere, so I'm not sure if there is a limit or not, but I'm just asking to be safe.

Thanks for the help.

(Lol, whoops... I wrote string in the title instead of list. My bad.)

3
Contributors
1
Reply
2 Hours
Discussion Span
1 Year Ago
Last Updated
2
Views
Question
Answered
Lemony Lime
Light Poster
25 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

To answer your second question, try it out yourself in IDLE, what a quick for loop that creates a list and adds 1000 lines of some random sentence. TIP: It works :-)

Your first question, sure I don't see anything that can't be done there. Just write the txt file line by line and add the prefix just before you write the line to the file.

gorbulas
Newbie Poster
11 posts since Apr 2010
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 1 Year Ago by gorbulas

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0545 seconds using 2.63MB