last day (15 days later) » 

4:01 PM
0
Q: How do I remove a random new line in the middle of a line in a text file using Python?

RuthThe following code will take the contents of 'out.txt' and append it to the end of 'fixed_inv.txt' in the form of a new file, 'concat.txt' based on a shared path. Sample lines of all files: 1) fixed_inv.txt 70 abc.def.com HRShared$ \vol\cor_q_share1\HRShared 34 NULL 3 4479242 Share ...

 
hey there! I think there is more than one suggestion to be made here. Thank you for posting the code you're working with, could you possibly include a few lines of the input file as well? Would like to share a few tips/tricks. Also, what OS are you using?
 
@snakes_on_a_keyboard hey, thanks for your comment! updated my question to answer yours :)
 
Thanks @Ruth! It would be really helpful if you could copy/paste those lines in :)
Also that looks like a sample output... we need a sample input. Or is that a sample input?
oh I see, are you attempting to correct the formatting error in these files? okay, sorry, let's back up. These files and the lines you're sharing that you say are in error: Are these files that you generated or are you trying to write code to correct errors in these files that are ALREADY generated?
 
I'm trying to take the contents of 'out.txt' and append it to the end of 'fixed_inv.txt' in the form of a new file, 'concat.txt' based on a shared path. My code runs, but the new file has a few lines that are messed up with the error mentioned above.
@Prune updated the question to address your comments, thank you!
 
ah, perfect, okay :) got it now. I'm sure plenty of answers are on the way.
Hey Ruth! Question: fixed_inv.txt and out.txt ... do the lines match up?
as in, can I assume line X on fixed_inv.txt corresponds with line X on out.txt?
 
4:03 PM
nope :(
they both have a different amount of lines. some lines match up based on the same path (vol/) though
order is different
will you be free in one hour? i'd like to grab lunch soon but if not that's no problem!
 
Hmm okay. Yeah sure go ahead and grab lunch. I'll hammer out a few suggestions and if it doesn't work we can keep working on it. :)
one last quick question if you don't mind
 
Sounds good, thank you snakes! :)
go for it
 
that resulting output line ... is that a result of all 3 of those lines put together?
that's the last piece of the puzzle
basically just need to how lines A1 + A2 + A3 + B1 + B2 + B3 = C if that makes any sense
 
it's adding the output of out.txt to the end of a line (if they have a matching path) in fixed_inv.txt
to make concat.txt
 
gotcha
okay, enjoy lunch!
 
4:08 PM
bless
thank you!!!
 
 
1 hour later…
5:12 PM
okay, I gotta run and do some work now... hope this helps :O
 
6:01 PM
i really appreciate it, you're very kind and helpful! good luck with your work!
i have a question about the solution when you get the chance
i get an error message that looks like this:
print("Unable to read {}!".format(fname), file = sys.stderr) ^ SyntaxError: invalid syntax
i want to be able to recreate this code myself so im tryna make it run first!
 

last day (15 days later) »