Questions tagged [file-handling]

file-handling is an abstraction of common actions such as creating, opening, closing, reading, updating, writing, comparing and deleting files

2915 questions
3
votes
2 answers

PHP - read huge amount of files from directory

I have a folder with huge amount pictures(10000 files at least) and I need to get names of all this files using PHP. The problem is when I use scandir() I got error about memory limit. Also, I tried to use code like this: $files…
3
votes
3 answers

How to Write Multiple Rows/Arrays to CSV File in one attempt using PHP?

I have to write multiple records in csv file. I'm using fputcsv function of php which take array as one row and write it in the file. In this way there will be multiple write operations for each row. I'm looking for a method with which I can write…
DesiHacker
  • 108
  • 2
  • 15
3
votes
2 answers

Read file changes since the last check without running program constantly in C#

I am trying to create a simple file monitor that checks for updates periodically in a log file and processes the updates. I tried using FileSystemWatcher but that requires my application to keep running forever. I am thinking more on the lines of…
jitendragarg
  • 945
  • 1
  • 14
  • 54
3
votes
4 answers

UnicodeDecodeError: 'cp932' codec can't decode byte 0xfc

import os for root, dirs, files in os.walk('Path'): for file in files: if file.endswith('.c'): with open(os.path.join(root, file)) as f: for line in f: if 'word' in…
Chetan.B
  • 139
  • 1
  • 2
  • 10
3
votes
1 answer

python - Reading all kinds of files in different encodings

I built a Python steganographer that hides UTF-8 text in images and it works fine for it. I was wondering if I could encode complete files in images. For this, the program needs to read all kinds of files. The problem is that not all files are…
TheRandomGuy
  • 337
  • 5
  • 20
3
votes
2 answers

Create multiple files from one text file in java

I have one input.txt file which consist on let suppose 520 lines. I have to make a code in java which will act like this. Create first file named file-001.txt from first 200 lines. then create another file-002 from 201-400 lines. then file-003.txt…
Adnan Ali
  • 2,851
  • 5
  • 22
  • 39
3
votes
3 answers

Error when extracting a filename to name other files

I am trying to use FFmpeg to convert a video to images in Bash. I would like to use the videos' filenames to name corresponding images (followed by a integer number). I was able to do this if I was exporting the files in the same directory: for…
Shawn
  • 33
  • 5
3
votes
1 answer

^Z character is written to the file or not?

I am writing text to a file using the following program. #include #include int main() { int ch; FILE *fp; fp = fopen("myfile.txt", "w"); if(fp == NULL) { printf("Error opening file\n"); …
Cody
  • 2,480
  • 5
  • 31
  • 62
3
votes
2 answers

What is file position pointer?

I am learning C using this site. Under fgetc() Function the author said: This function reads a single character from a file and after reading increments the file position pointer. FILE *fp; fp = fopen(filename, "r"); What I want to ask is that…
Cody
  • 2,480
  • 5
  • 31
  • 62
3
votes
1 answer

How to write a file in external sd card and not in device storage?

I tried this: public String getFilename() { File file = new File(Environment.getExternalStorageDirectory(), "Test2"); if (!file.exists()) { file.mkdirs(); } String uriSting = (file.getAbsolutePath() + "/" + "IMG_" +…
Bugs Buggy
  • 1,514
  • 19
  • 39
3
votes
1 answer

How to convert scriptlets into jstl tags

I tried turning these scriptlets into jstl tags with no success, is it not doable with these lines of codes, and if it can how so? thanks <% //String file = application.getRealPath("C:/science/"); File f = new File("C:/uploads"); …
Yomk
  • 33
  • 3
3
votes
1 answer

How do I batch copy and rename files with same name in different path?

I have a set of folders, inside each folder I have several sub-folders. In each sub folder there is a file called result.txt I need all the result.txt to be copied to other location renaming result files. folders: abc1 efg1 doc2 …
anonymous
  • 65
  • 1
  • 10
3
votes
4 answers

Python Read String from File with Strange Encoding

I made a pig latin translator that takes input from the user, translates it, and returns it. I want to add the ability to input a text file to take text from but I'm running into an issue that the file isn't being opened as I expect. Here is my…
Supetorus
  • 79
  • 2
  • 10
3
votes
2 answers

Under which circumstances will the python f.readlines method fail?

I use the code below to read in a text file (always a few thousand lines long). Is the except Exception as e block unnecessary? try: in_file=open(in_file,'rU') try: in_content=in_file.readlines() except Exception…
Slothworks
  • 1,083
  • 14
  • 18
3
votes
2 answers

Passing an open file from one function to another

I'm a python beginner so bear with me. I have written some code on a GUI that allows users to select a file using one button (browse_inputfile), it then displays the file path and then the user can click another button to run a conversion on that…
Carmen C
  • 63
  • 1
  • 8