Questions tagged [file-manipulation]

219 questions
4
votes
1 answer

Use tr to remove line breaks in multiple files?

I have a set of several hundred .txt files that I am analyzing (ngram analysis using NSP), and I need to remove all the line breaks from each file. I can do it one at a time using tr: $ tr -d "\n\r" < input1.txt > output1.txt How can I do this for…
Ted Maclin
  • 43
  • 1
  • 1
  • 3
4
votes
4 answers

Python newbie: trying to create a script that opens a file and replaces words

im trying to create a script that opens a file and replace every 'hola' with 'hello'. f=open("kk.txt","w") for line in f: if "hola" in line: line=line.replace('hola','hello') f.close() But im getting this error: Traceback (most recent…
tirenweb
  • 30,963
  • 73
  • 183
  • 303
4
votes
5 answers

How to read lines without iterating

I have a text file, and I have a condition set up where I need to extract a chunk of text every other line, but the chunk of text can be any amount of lines (a FASTA file, for any bioinformatics people). It's basically set up like this: > header,…
biohax2015
  • 281
  • 2
  • 6
  • 15
4
votes
2 answers

Does Directory.GetDirectories(path) return full paths or just names?

In the MSDN documentation, it says it returns just directory names("Return Value Type: ... An array of type String containing the names of subdirectories in path."), however in their example code, they recurse without concatenating them, so does…
Ed James
  • 10,385
  • 16
  • 71
  • 103
4
votes
2 answers

Perl finding valid pairs of lines among different cases

I have HTTP header request and reply data in tab delimited form with each GET/POST and reply in different lines. This data is such that there are multiple GET, POST and REPLY for one TCP flow. I need to choose only the first valid GET - REPLY pair…
sfactor
  • 12,592
  • 32
  • 102
  • 152
3
votes
1 answer

Powershell script that prompts user

How would I go about adding a delete feature to my script that is similar to the rename one? Where it opens up the file browser and allows a user to select a file to delete? Is it possible or do I have to do it another way? I need help with option 3…
user16240971
3
votes
3 answers

Delete unecessary .keep files

I noticed my git repository has a lot of .keep files. They were once useful when their parent directories were otherwise empty, but since then a lot of the directories now have real children that keep them alive in git. Is there a nice way to remove…
Alexander
  • 59,041
  • 12
  • 98
  • 151
3
votes
2 answers

Python: How to get the full path of a file in order to move it?

I had files that were in zips. I unzipped them with Zip-7 so they are in folders with the zip file names. Each of these folders has either a .otf or .ttf (some have both) that I want out of them and moved to another folder. I have tried a few…
BSinGoogle
  • 33
  • 3
3
votes
1 answer

Hashmap single key holding a class. count the key and retrieve counter

I am working on a database self project. I have an input file got from: http://ir.dcs.gla.ac.uk/resources/test_collections/cran/ After processing into 1400 separate file, each named 00001.txt,... 01400.txt...) and after applying Stemming on them, I…
Rebin
  • 516
  • 1
  • 6
  • 16
3
votes
1 answer

how to find whether a substring in file is already present in hashmap?

I have a hashMap(guava bimap) in which keys and values both are strings, I wanted to write a program which parses the given file and replaces all the strings in the file which are also in BiMap with corresponding values from Bimap. for example: i…
3
votes
2 answers

Codeigniter and uploading zip files

I am currently building a backend to a site using the codeigniter framework, I have hit a bit of a problem, I needing a way to allow the user to upload a zipped folder of images, on completing the form, zipped folder must be unzipped, and the files…
Udders
  • 6,914
  • 24
  • 102
  • 194
3
votes
4 answers

Python script writes text to file, but doesn't add the text it's supposed to

I'm ashamed to resort to asking for help again, but I'm stuck. I have a spanish novel (in plain text), and I have a Python script that's supposed to put translations for difficult words in parentheses, using a custom dictionary in another text file.…
Yngve
  • 743
  • 4
  • 10
  • 15
2
votes
7 answers

How to find extra lines by comparing two files using php?

I have two files. First one has 482 lines. Second one has only 519 lines. I would like to find extra lines by comparing two files using php. Lets say my first file has lines like this Mango Orange Cherry Apple Blackberry And lets say my second…
Giri
  • 4,849
  • 11
  • 39
  • 48
2
votes
2 answers

Handle / access files on the disk

I'm using Java with JSF an Glassfish 3 container. In my web application I'm trying to implement a file(image) management system. I have a config.properties file from where I read the path where the uploaded images should be…
Ionut
  • 2,788
  • 6
  • 29
  • 46
2
votes
2 answers

Find X-largest values in a large file with optional input file command line parsing method in C++

I have a file in the following fixed format: e.g. 1426828011 9 1426828028 350 1426828037 25 1426828056 231 1426828058 109 1426828066 111 . . . I want to write a program that reads from…
Hector Ta
  • 81
  • 2
  • 14
1
2
3
14 15