Questions tagged [txt]

txt is the conventional filename extension of text files.

1467 questions
2
votes
1 answer

How to save a Float array in Swift as txt file

First of all: I really want to save the array as .txt file. .plist is out of the question. The reason: Afterwards I want to save it to a vector using C++. Realizing this with a wrapper already drove me crazy. Here is my code: guard let buf =…
2
votes
4 answers

Python: Extracting first element from each line of a CSV file

I would like to read from a csv file and add certain things to a list JFK,John F Kennedy International,5326,5486 ORY,Paris-Orly,629,379 MAD,Adolfo Suarez Madrid-Barajas,1428,1151 AMS,Amsterdam Schiphol,526,489 CAI,Cairo…
Proxy
  • 43
  • 1
  • 4
2
votes
1 answer

Reading a txt file line by line with skip function of every second line and the output saved as a dataframe using R

I would be grateful for some help with reading a text file line by line and skipping lines (1,3,5,7). The input file looks like this: >Q5W0Q7|5-5|ength_1092 DMESPVFAFPKALDLETHIEKLFLY >Q6PEW1|2-2|length_402…
student24
  • 252
  • 1
  • 9
2
votes
2 answers

Replace a value if this value is present in a txt file

Goodmorning everyone, I have a data.ped file made up of thousands of columns and hundreds of lines. The first 6 columns and the first 4 lines of the file look like this: 186 A_Han-4.DG 0 0 1 1 187 A_Mbuti-5.DG 0 0 1 1 188 A_Karitiana-4.DG 0 0 1…
Nuthatch92
  • 91
  • 7
2
votes
1 answer

Remove directory path from grep -r output

I am running grep -r to look for the context of a word in multiple files. I am using -r to do it recursively, -i to ignore case and -C to get lines below and above: grep -r -i -C 10 --group-separator="==========" "29/04/2020" "$dir" >>…
Tiago Lubiana
  • 319
  • 1
  • 11
1
vote
3 answers

Bash script for TXT file to JSON conversion parsing issue

I have to create a simple bash script that converts .txt outputs to JSON code. The pattern is as follows: [ Example ], 1..3 tests ----------------------------------------------------------------------------------- not ok 1 text1 (text1), 5ms ok 2…
Nysa-522
  • 49
  • 3
1
vote
1 answer

Is there a way to access .txt files from a private Github repo in Python without using the raw version or cloning the repo/downloading the files?

I've created a private repo on Github and need to access a .txt file from the repo in a Python script I am writing. I was able to access the .txt file using the https://raw.githubusercontent.com/ url which has a token at the end, but the token…
prismarine
  • 15
  • 1
  • 3
1
vote
1 answer

How to use R baseline package with txt file as input

I want to use the baseline package in R to correct my RAMAN spectra. My spectra data are in txt files without headers. I know the baseline package needs a matrix with all data in one row. I tried to convert my files and use the baseline package, but…
Ina
  • 13
  • 3
1
vote
1 answer

How to read in dataset containing special characters in pandas

I am trying to read in the following dataset: https://data.opensanctions.org/datasets/20230620/default/names.txt I have run this code: filename = "https://data.opensanctions.org/datasets/20230620/default/names.txt" df = pd.read_csv(filename,…
Giampaolo Levorato
  • 1,055
  • 1
  • 8
  • 22
1
vote
1 answer

Read unique values from txt file with pandas

I have a txt file which is formatted in this way: thi is a junk data line to be ignored abc xyz dsfgsrj AFKSDNG-RBI 20200706 MARS stu base-1 AFKSDNG-UBI 20200706 JUPITER uyt base-2 AFKSDNG-ABI 20200706 MARS …
twww123
  • 37
  • 7
1
vote
2 answers

Trying to rewrite text files in 'Latin-1' results in wrong characters for letters with accents

I am trying to open and change several text files. My files are in 'Latin-1' but when I use f.read all the letters with accents are converted into "ã". My code is: for dname, dirs, files in os.walk("mydirection"): for fname in files: …
MG Fern
  • 75
  • 9
1
vote
0 answers

My Macro only works the 2nd time I run it, first time I run it imports the Text file but does not format

This is the VBA I currently have, I have to run it twice in order to properly format. I get no error boxes my first time running it just copies the unformatted text into my tab at my destination c6 I am using fileToOpen as the file changes daily and…
1
vote
1 answer

Pandas - Passing working values from read_csv to a DataFrame turns everything to NaN, why?

I'm working on a script which reads a bunch of txt files into pandas for data processing. A sample of a text file would…
Andreas
  • 13
  • 2
1
vote
3 answers

trying to remove newlines from file in python each time i run it

im trying to use the logging module to save some logs in a external file, while using the .getLogger() attribute to change the logger name in another log file... still the one problem im having is just when im trying to write the log. It will always…
1
vote
1 answer

Trying to Read CSV Files in PySpark but it is also reading Text Files

I have a folder having .txt and .csv files (having exactly same column names) However, while I am trying to read only CSV Files in PySpark and trying the following code below it is reading and appending both text and csv files together from…
RajatK350
  • 71
  • 8