Questions tagged [txt]

txt is the conventional filename extension of text files.

1467 questions
-1
votes
1 answer

Problem with duplicate data in fgets with structs

I have a program that seems to have a problem displaying the data received from a .txt file with fgets Basically the program is something similar to a CRUD or ABM (in Spanish). The problem is that when I show the structs from the file, it shows me a…
-1
votes
1 answer

Convert a txt file to json file with powershell

I have a txt file: orange : 1 blue : 2 yellow : 3 And i want to convert this file to json which look like that : { "colors-20220906" : { "orange" : 1, "blue" : 2, "yellow" : 3 } } Add a key with a timestamp. Could you help me…
kgv34
  • 1
  • 1
-1
votes
1 answer

OSError: [Errno 22] Invalid argument with a \r

I use JSON to make .txt files but when I make them with this with open("Saves/" + setname + ".txt", "w") as savefile: json.dump(data, savefile) ... I get this: Traceback (most recent call last): File…
Plazm air
  • 1
  • 2
-1
votes
1 answer

How to save looped output in C++ to a .txt file with columns and rows

I'm a C++ newbie and am wanting to save outputs that are printed when looping over several files. The outputs are 3 floats, which are called mass_pole, sum, and sum_SM. How do I save these looped outputs (without overwriting them) to a .txt file…
Phoenyx
  • 1
  • 2
-1
votes
1 answer

Text box does not update after changing after selected item in ComboBox (ComboBox gets the list from a text file)

I am confronting with an issue with the ComboBox in a WinForms app. The combo box contains a list with items that are grabbed from a TXT file. To read and update the list I added the following code to Form_Load. string[] lineOfContents =…
-1
votes
1 answer

Can't compare string in file and user input properly

My assignment is as follows: Add a naughty word to the list Show all naughty words in the list Input sentence needing to be censored I need to save naughty words in a file and compare if the user input contains a bad word, so i can censor it with…
-1
votes
2 answers

How to read txt file using Springboot?

I need to read a txt file using Springboot. This txt file consist of several words and need to assign those words in to a String Array. How can I do that?
-1
votes
2 answers

How could I get the rows full of values in a txt file?

I've been struggling on a problem for a few hours. I've a data-set which looks like this : References 425 1451 259 /1/J.H.Gibbons,R.L.Macklin:Phys.Rev.B137,1508(1965) 425 1451 …
hhvni
  • 1
  • 1
-1
votes
1 answer

delete a specific line in txt file if it consist a special word

i ask for a input, if that input was in a line of my txt file, delete just that line w = input("Enter STnumber: ") with open("student.txt ", "r") as f: lines = f.readlines() with open('student.txt','w') as f: for line in lines: …
Payam_2021
  • 19
  • 5
-1
votes
1 answer

Error Index out of Bound when trying to write data to new .txt file

I am trying to write a specific portion of data from a .txt file to a different .txt file for later use. Code is below. file = open(path, newline='') reader = csv.reader(file) header = next(reader) data = [row for row in reader] #read only…
John
  • 25
  • 9
-1
votes
4 answers

Python: Import comma separated data from a TXT file

I built a data logger with a Raspberry Pi Pico. The Data Logger saves the temperature every six minutes in the TXT file. I am currently failing to import the data from the TXT file into Python. The data looks like…
jonas.weik
  • 13
  • 2
-1
votes
3 answers

How can I check if a txt file only contains whitespaces

with open('save.txt', 'r') as fname: data = fname.readlines() print(data) x = str(data) if x.isspace(): print("only whitespaces") else: print("not only whitespaces") I have tried this but it seems it doesnt work.…
AfterHover
  • 97
  • 2
  • 12
-1
votes
2 answers

Tail and search in txt file

I need to make a search on a txt file. Originally I've thought to open the file and search for the word I'm looking for on the last line remote_file = sftp_client.open('file.txt') try: lst = list(remote_file.readlines()) …
Inuyasha84
  • 50
  • 9
-1
votes
2 answers

convert txt with empty lines in csv

I have many files like the following: cat test.data name1 ... nameN title1 ... titleM abstract1 ... abstractO ID where the numbers N,M,O differ from file to file. But in all files the fields are separated by empty lines. I want to transform…
-1
votes
1 answer

Extract a chunk of text from a .txt file (Python)

I have a text file that contains 4 parts that I want to extract. I managed to get 3 of them but am struggling with the last one as it has a different marker. Can anyone please help me out. below is a chunk of the text file. *** Marker: DHT (Define…
NBG
  • 30
  • 7