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
0
votes
0 answers

Unable to copy a .png(image) file in the system in c++ can anyone help me how to do this?

#include #include using namespace std; main() { ifstream a1; ofstream o1; a1.open("fail.png",ios::binary); o1.open("fail2.png",ios::binary); long long int t; t=a1.get(); while(!a1.eof()) { // cout<
0
votes
2 answers

What's a better way to delete a row of text from a text file?

I want to delete a row of text from a text file. This is my code: with open("contactbook.txt","r") as file: for num, line in enumerate(file, 1): if args.name in line: filedata = file.read() filedata =…
Rose
  • 127
  • 7
0
votes
2 answers

How do I add a linebreak at the end of a string in text files?

I tried doing this: with open("contactbook.txt","a") as f: f.write("hello\n") But it gets printed as: 'hello\n' My code to read the file: with open("contactbook.txt","r") as f: lines = sorted(f.readlines()) print(lines) EDIT: I…
Rose
  • 127
  • 7
0
votes
0 answers

Split Filenames with the help of names in another file and save the text file in Directory

I am on Windows. This might be a simple question but I don't know how to use the OS module to conduct the following I have a folder named 'modules' with a few text files. File location: F = C:\\X\\Data\modules And within this folder I have about…
user13973446
0
votes
1 answer

peek of closed file error while reading a binary file

I am trying to insert some data from files into a MySQL database. However, while reading a file it shows an error. This is my code for inserting into the database from files to a MySQL database: import mysql.connector import pickle try: …
0
votes
2 answers

MYSQL not accepting values from insert statement

So im trying to insert values into a MYSQL database table but the following error keeps on popping up. would really appreciate some help. This is my code which i wrote to input a value from a file and store it in a database table. import…
0
votes
1 answer

File to String Null Pointer Exception

I'm trying to pass the contents of a file into a method as a String and encountering a Null pointer exception. I'm converting the file into a String like so: import java.io.*; public class FileHandler { String inputText = null; public…
0
votes
3 answers

Is there a way to print data from a log file between two endpoints in python

I have a log file and am trying to print the data between two dates. 2020-01-31T20:12:38.1234Z, asdasdasdasdasdasd,...\n 2020-01-31T20:12:39.1234Z, abcdef,...\n 2020-01-31T20:12:40.1234Z, ghikjl,...\n 2020-01-31T20:12:41.1234Z,…
NiK K
  • 11
  • 2
0
votes
1 answer

Can you provide and example of utl_raw.convert + utl_raw.cast_to_varchar2?

Can somebody please tell me how the utl_raw.convert works with utl_raw.cast_to_varchar2 in Oracle 11g by giving a sample code as i am not able to find an example use case online. Thanks Gautam
Gautam S
  • 41
  • 1
  • 1
  • 7
0
votes
2 answers

Python Not able to append new line character after the end of a line when writing to a new file?

In below method I am sorting the contents of the file according to timestamp , and it's working fine also But I don't know how to append new line when I am writing to a newly made file.It is writing in the same line I want to change the lines in my…
Ankur
  • 457
  • 6
  • 21
0
votes
2 answers
0
votes
1 answer

Python Sorting the contents of the file according to the timestamp and write it to new file?

I have the file which stores the data in the below…
Ankur
  • 457
  • 6
  • 21
0
votes
0 answers

C++ File handling Program

Here I have tried to write a program write, update, display, delete, and print record. Display a menu of option and select an option to execute it. Problem is that, "Neither default switch statement is executed nor 3 to 6 option executed." Can…
0
votes
0 answers

How to remove Error message: No such file or directory found Python?

path="C:\Users\Manav\Desktop\txtfile.txt" f = open(path,mode='r') The file (txtfile.txt) is on the desktop. I have tried a few things now but still the error persists.I use jetbeans pycharm. Used double '' too. Can anyone help me out?
Manav
  • 1
  • 2
0
votes
2 answers

why python is dropping errors after execution is being completed

I write the program that penetrate inside the folder and check if folder have sub folders that either contained files or not if there is folders which contained files inside program penetrate into it again and delete all founded files in order to…
Umutambyi Gad
  • 4,082
  • 3
  • 18
  • 39