Python Forum
Two text files, want to add a column value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two text files, want to add a column value
#5
Thanks, this looks more like what I need.

Question - how do I remove the hardcoded values in this bit :

f1 = io.StringIO("""
20220617 14:30:00, 1.1
20220617 14:40:00, 1.3
20220617 14:50:00, 1.7
20220617 15:00:00, 1.4
""")

...and instead, specify a filename on my directory. For example, I'd love to say
f1 = io.StringIO(filename)

but of course this does not work. I've read up on the online documentation for StringIO and couldn't find an example
of reading an actual file.
Reply


Messages In This Thread
RE: Two text files, want to add a column value - by zxcv101 - Jun-19-2022, 09:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  azure TTS from text files to mp3s mutantGOD 2 1,869 Jan-17-2023, 03:20 AM
Last Post: mutantGOD
  Writing into 2 text files from the same function paul18fr 4 1,817 Jul-28-2022, 04:34 AM
Last Post: ndc85430
  Delete empty text files [SOLVED] AlphaInc 5 1,702 Jul-09-2022, 02:15 PM
Last Post: DeaD_EyE
  select files such as text file RolanRoll 2 1,302 Jun-25-2022, 08:07 PM
Last Post: RolanRoll
  select Eof extension files based on text list of filenames with if condition RolanRoll 1 1,625 Apr-04-2022, 09:29 PM
Last Post: Larz60+
  Append files and add column with last part of each filename NiKirk 0 2,736 Feb-04-2022, 07:35 AM
Last Post: NiKirk
  Separate text files and convert into csv marfer 6 3,068 Dec-10-2021, 12:09 PM
Last Post: marfer
  Sorting and Merging text-files [SOLVED] AlphaInc 10 5,243 Aug-20-2021, 05:42 PM
Last Post: snippsat
  Replace String in multiple text-files [SOLVED] AlphaInc 5 8,473 Aug-08-2021, 04:59 PM
Last Post: Axel_Erfurt
  Several pdf files to text mfernandes 10 6,097 Jul-07-2021, 11:39 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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