txt is the conventional filename extension of text files.
Questions tagged [txt]
1467 questions
2
votes
2 answers
Create txt file from Pandas Dataframe
I would like to save my dataframe in a way that matches an existing txt file (I have a trained model based on the this txt file and I now want to predict on new data, that needs to match this format).
The target txt file looks like this (first3…

Tartaglia
- 949
- 14
- 20
2
votes
1 answer
Write array to .txt-file
In Python I need to write a list of numpy-arrays (see attached picture) to a txt.-file and then reuse that original list of arrays in a new python-file. How can I do that?
read_files = open("read_files.txt","w+")
content =…

yessir22
- 35
- 4
2
votes
2 answers
Opening a C++ .txt file using user-input
I'm trying to open a C++ .txt file as shown in my code below. This is part of a larger program that I'm working on where I write the contents of one file into another so that it contains the same information as the original but I am required to…

joemamah24
- 35
- 5
2
votes
1 answer
How to keep lines which contains specific string and remove other lines from .txt file?
How to keep lines which contains specific string and remove other lines from .txt file?
Example: I want to keep the line which has word "hey" and remove others.
test.txt file:
first line
second one
heyy yo yo
fourth line
Code:
keeplist =…

Karim Mostafa
- 23
- 3
2
votes
1 answer
Csv file 2d array and txt file 2d array comparison
def read_text_file(filename):
with open(filename, 'r') as file:
array = [line.split() for line in file]
return array
array = read_text_file("file.txt")
print(array[0][1])
Gives a list out of range error
import csv
with…

Josh
- 31
- 4
2
votes
0 answers
Convert text file into array of objects
I have this TXT file:
{ input: [0,0], output: [0], id: 232362 }
{ input:[0,1], output: [1], id: 232363 }
I would like to convert it into array of objects in Typescript this way:
[
{ input: [0, 0], output: [0] },
{ input: [0, 1], output:…

Jirka
- 21
- 2
2
votes
2 answers
pd.read_csv column misalignment
I have a text file containing two columns, but when I want to read the data using Pandas, the columns and the data are misaligned.
Here's my code for reference:
import pandas as pd
filename = r'data.txt'
#read text file into pandas DataFrame
df =…

Jumo
- 23
- 5
2
votes
2 answers
How do I display Text in a Tk Window
I'm trying to post the text from a .txt file in text screen on a Tk window, but every time I click on the the file to display I get an error that says
FileNotFoundError: [Errno 2] No such file or directory: 'dffffff.txt'
How do I fix this…

Cristan Erwin
- 21
- 2
2
votes
2 answers
How to create a pandas dataframe from a txt file with comments?
I need to create a pandas dataframe based on 4 txt files with comments (to skip while reading) based on the following structure:
# Moteur conçu par le Poly Propulsion Lab (PPL)
nom=Tondeuse
# Propriétés…

Jotunes
- 33
- 4
2
votes
2 answers
Python: Separate text file data into tuples?
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:
…

giotto1
- 49
- 5
2
votes
1 answer
txt file with different seperators to lists of integers
I have a txt file with integers, some seperated by spaces and some seperated by comma's.
it looks like this:
7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1
22 13 17 11 0
8 2 23 4 24
21 9 14 16 7
6 10 3 18 5
I want…

Willem12345
- 23
- 3
2
votes
3 answers
Import CSV with every row containing the column headers
I'm dealing with a csv that repeats its headers name within each rows:
player: John Doe ; level: 45 ; last_login: 7854414174 ; coins: 7600
player: Anckx Uj ; level: 471 ; last_login: 7854418847 ; coins: 684111
I'd like to know how I can only select…

kirstendo
- 31
- 2
2
votes
2 answers
read position based txt
I have a txt file that I read into a list of strings in which each item of the list is a data sample of 3 variables (A,B,C)
txt = [
'001 0198110',
'0020130198110',
'0030132198110',
]
A separate support dataframe that looks like…

gabboshow
- 5,359
- 12
- 48
- 98
2
votes
1 answer
Python Txt File Replacement - 'str' object does not support item assignment
Suppose I have a txt file like below
3 113.12747240513697 -1.0352096627496632 14.963682795503324
3 10.892386778099667 10.556798857881242 2.017821533523687
2 15.532838824289408 11.761144702842378 -5.862336401808785
2 10.892386778099667…

drorhun
- 500
- 7
- 22
2
votes
1 answer
show interfaces description cisco to txt <-> csv python
I'm trying to convert from a txt file to another csv file but why can't do how can I need.
I got this txt:
Interface Status Protocol Description
Gi1 up up MANAGEMENT INTERFACE…

Martin Barbieri
- 91
- 6