Questions tagged [txt]

txt is the conventional filename extension of text files.

1467 questions
1
vote
0 answers

enhanced for loop comes up null for the variable tName

String name = appMenu.promptToyName(); Toys tName = searchByToy(name); System.out.print(tName.format()); private Toys searchByToy(String toyName) { Toys tName = null; for(Toys t: toys) { if…
1
vote
1 answer

Convert txt python dictionary file to csv data file?

I have a text file with 300,000 records. A sample is below: {'AIG': 'American International Group', 'AA': 'Alcoa Corporation', 'EA': 'Electronic Arts Inc.'} I would like to export the records into a csv file like this: I tried the following, but…
HTMLHelpMe
  • 197
  • 6
1
vote
1 answer

Pandas Read txt with ID duplication on the end

I would like to ask for help with the following problem: I need to use a downloaded txt data with this duplicate id at the end of the row structure. UID value1 value2 A01 99 10 A01 A02 29 12 A02 A03 96 14 …
1
vote
0 answers

I receive (OSError: [Errno 9] Bad file descriptor) when attempting to open and append a file in python

I am creating a simple flask website with a login and register page. The login page works fine with login information stored in a csv file. On the register page, after validating username and password, my code fails when attempting to append the csv…
JavaNewb
  • 23
  • 5
1
vote
1 answer

Read txt files in google colab using google drive

I would like to read txt files using google drive. In my google drive I have a dataset into this folder '/content/gdrive/My Drive/DATASETS/DOXES/*.txt' the data looks like this 1) For some reason I cannot see in the ending of names the txt, is that…
1
vote
4 answers

Reading in tab-delimited txt file in chunks?

I have a txt file, and here is a snippet of the first few lines: C A10231 A1 171|171 HER C B23098 A1 171|171 HEF C A03295 A2 171|171 HAF I want to create a running list of every time the third column reads…
1
vote
2 answers

How can I separate data where no of fields not matching in each row using spark

I am trying to filter records which donot have expected number of fields in row below is my code no_of_rows_in_each_column=3 delimiter = "," input.csv emp_id,emp_name,salary 1,"siva Prasad",100 2,pavan,200,extra 3,prem,300 …
K Soumya
  • 71
  • 6
1
vote
2 answers

Convert pandas to txt in google colab

I have a dataset which called preprocessed_sample in the following format preprocessed_sample.ftr.zstd and I am opening it using the following code df = pd.read_feather(filepath) The output looks something like that index text 0 0 i really…
1
vote
0 answers

Same code but different output with PyPDF2 and without PyPDF2, not sure why

Im extracting text from a pdf and passing it into a .txt fillet afterwards clean it up and select the parts I want to keep. So I installed the PyPDF2 library. I managed to extract the text from the pdf and copy it into a .txt file. But when I print…
Arthur
  • 11
  • 4
1
vote
2 answers

How to I merge multiple .txt files that are in a .zip file into only one .txt file in Python?

I'm trying to merge multiple .txt files that are in a .zip file into only one .txt file in Python. My code is the following: firstfile =…
ViniPonce
  • 13
  • 2
1
vote
2 answers

How to reduce computational cost with Regex function

I am trying to use regex to extract sentences containing specific words, and sentences before and next to them. My code works, but it takes 20 seconds for each txt and I have about a million txt files. Is it possible to get the same result in less…
1
vote
3 answers

How to make a script that merges all .txt files into one .csv file into multiple columns in Powershell

I don't know how to merge multiple .txt files with datas into one .csv file each of the .txt file seperated into columns. This is my code so far, $location = (Get-Location).Path $files = Get-ChildItem $location -Filter "*.asd.txt" $data =…
GetTheLoot
  • 13
  • 3
1
vote
1 answer

how to open several nc files, filter a desired period and write the result in a single txt file?

I have several nc files, I need to open them all. Filter the desired period and write the result of all in a single txt file. The nc files correspond to a month (Jan, Feb, Mar...) and have four variables (temperature, dew point, u and v). I need to…
1
vote
1 answer

Python ping by reading txt file contain list of IP address and string or name next to it

I'm testing running simple script to ping few servers by calling a text file iplist.txt. The script working if txt file only contain IP address. Now I'm adding hostname next to the IP address in the iplist.txt and ping failed. Original only IP…
chenoi
  • 575
  • 3
  • 8
  • 30
1
vote
2 answers

replace specific string in a txt file, but only in certain lines

txt file with 40000 lines. In each lines are comma seperated numbers. I want to remove a specific number in the lines 36000 to 39000. For example number 233. But i dont want to remove the string from number 23341. Here is my code so far: with…