txt

How to combine every 4 lines in a txt file?

How to combine every 4 lines in a txt file? Question: I have a txt.file that looks like this: data1 data2 data3 data4 data5 data6 data7 data8 data9 data10 data11 data12 data13 data14 data15 data16 data17 data18 data19 data20 data21 data22 data23 data24 . . . and I want to rearrange my txt file so …

Total answers: 3

Python: Separate text file data into tuples?

Python: Separate text file data into tuples? Question: I’m currently working on trying to separate values inside of a .txt file into tuples. This is so that, later on, I want to create a simple database using these tuples to look up the data. Here is my current code: with open("data.txt") as load_file: data = …

Total answers: 2

Split CSV file which contains multiple tables into different pandas dataFrames (Python)

Split CSV file which contains multiple tables into different pandas dataFrames (Python) Question: I have multiple CSV files which are formatted with multiple tables inside separated by line breaks. Example: Technology C_inv [MCHF/y] C_maint [MCHF/y] NUCLEAR 70.308020 33.374568 HYDRO_DAM_EXISTING 0.000000 195.051200 HYDRO_DAM 67.717942 1.271600 HYDRO_RIVER_EXISTING 0.000000 204.820000 IND_BOILER_OIL 2.053610 0.532362 IND_BOILER_COAL 4.179935 1.081855 IND_BOILER_WASTE 11.010126 …

Total answers: 1

Sort a txt file based on numbers

Sort a txt file based on numbers Question: I have a txt file of data that looks like this: @0 #1 @30 #2 @750 #2 @20 #3 @500 #3 @2500 #4 @460 #4 @800 #1 @2200 #1 @290 #2 @4700 #4 @570 #1 How do I sort the file based on the integer between the …

Total answers: 2

From text doc to JSON with python

From text doc to JSON with python Question: Suppose I have multiple txt files that look like this (indentation is 4 spaces): key1=value1 key2 key2_1=value2_1 key2_2 key2_2_1=value2_2_1 key2_3=value2_3 key3=value3 How do I convert one (or all) of them into this format: { ‘key1′:’value1’, ‘key2’: { ‘key2_1′:’value2_1’, ‘key2_2’: { ‘key2_2_1′:’value2_2_1’ }, ‘key2_3′:’value2_3’ }, ‘key3′:’value3’ } or …

Total answers: 1

decode string "2A4CT2A2C…" into "AACCCCTAACC…" from a text file to another

decode string "2A4CT2A2C…" into "AACCCCTAACC…" from a text file to another Question: I have a doc.txt which is like "2A4CT2A2C…" and i want to get "AACCCCTAACC…" and then write it to another doc1.txt I have tried: (origin and destination are the paths of the docs) def decode_txt(origin, destination): h = open(destination, "w") f = open(origin, …

Total answers: 3

Merge two list to create a table in a txt file in python

Merge two list to create a table in a txt file in python Question: I want to merger these two list in one list that should look like this : newlist = [‘Salle 13tBullet, Train Cartern’,’Salles 06t Sita Ramam, L’année du requinn’…] so each "salle" will have two names Here the two list needed to …

Total answers: 1

I want to keep only the lines before a certain string in a txt file

I want to keep only the lines before a certain string in a txt file Question: I want all lines before the line that has string ‘VarList’. I cannot understand why the solutions proposed elsewhere do not work for my txt file. To simplify: I have many .txt files that look like this: text1=text text2=text …

Total answers: 2