Questions tagged [file-read]

This tag can be used on questions about reading files.

To work with stored data, file handling belongs to the core knowledge of every programmer. One of the core file handling methods is reading a file.

Resources:

577 questions
-2
votes
1 answer

File Reading for Console

Am making a dictionary and have to read various file from various folder of various types! i have found the code for displaying folder in a directory on console! however i dnt understand how to read the txt files inside those folders! and display…
Plotter
  • 39
  • 1
  • 1
  • 12
-2
votes
4 answers

php file read function

I am using the following file read $myFile = "file.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); echo $theData; problem is file.txt is generating dynamically and is in different folder so how do I call it…
user1561466
  • 71
  • 1
  • 3
  • 11
-3
votes
1 answer

Reading the content of a css file using Java

I am trying to read a css file, find out the css classes and their definition and then save it in a csv file with its class name and description. Using Java, the following I have css file, common.css. /* CSS Document */ .Page { …
Vaishali
  • 11
  • 1
  • 5
-3
votes
2 answers

Escape characters when joining strings

Trying to read a .csv file content from folder. Example code: Files_in_folder = os.listdir(r"\\folder1\folder2") Filename_list = [] For filename in files_in_folder: If "sometext" in filename: …
-3
votes
2 answers

python to find line within a text file

I have a text file with entries like these: address-object ipv4 "DRV FIL01" name "DRV FIL01" ID 00000000-0000-002a-0100-c0eae46ae3f4 zone LAN_General host 10.4.12.7 address-object ipv4 "DRV FIL02" name "DRV FIL02" ID…
-3
votes
1 answer

Read a file and put specific values to an array

I am a newbie to bash scripting. I have a file containing some values. I want to put all the values of a specific key into an array in bash. The file looks like this. file.properties name=val1 name=val2 name=val3 age=val4 I want to read this file…
-3
votes
1 answer

C++ read different kind of datas from file until there's a string beginning with a number

In C++, I'd like to read from an input file which contains different kind of datas: first the name of a contestant (2 or more strings with whitespaces), then an ID (string without whitespaces, always beginning with a number), then another strings…
chuck
  • 63
  • 9
-3
votes
1 answer

Java read file line by line to a specific seek position

I want to read a file line by file to a specified seek position. It is easy to start reading from a certain seek position and read further till end. RandomAccessFile f = new RandomAccessFile("file.txt","r") f.seek(seek) This set file reading…
Shashwat Kumar
  • 4,541
  • 2
  • 24
  • 49
-3
votes
1 answer

Read points from a stream that is only one line

I have a file which first tells me how many points will I be reading on the following line. So, for example my file look like this: 7 a,b c,d e,f g,h, i,j k,l m,n So I know the following line after 7 is 7 pairs of integers separated by a comma and…
David Merinos
  • 1,236
  • 1
  • 12
  • 30
-3
votes
4 answers

Need help to read specific line in a log which ends with specific word

I need help on java code to read a log file that can print all lines present ends with START word. my file contains: test 1 START test2 XYZ test 3 ABC test 2 START it should print test 1 START test 2 START I tried below code but it printing…
smriti
  • 1,064
  • 5
  • 14
  • 33
-3
votes
2 answers

How can I determine what I read from a file? Java

So I want to read a file, that contains numbers separated by spaces. For example, the file "try.txt" content is: 1 2 3 4 5 6 7 8 9 I know how to read this numbers and store them in an array with a Scanner, and two nested for loops.Ignore any…
AliAs
  • 93
  • 1
  • 1
  • 10
-3
votes
2 answers

Importing certain details from a 'txt' file

I have a .txt file where names and addresses appear in the following format: Sam, 35 Marly Road ... ... I want to be able to search Sam and for 35 Marly Road to come up. Here is the code I have so far: name = input("Please insert your required…
A.Yasin
  • 1
  • 1
-3
votes
2 answers

Text File to Lua Array Table

I need to transfer a text from a text file/string to a Table with a 2 positions vector. Like this: Text File: Gustavo 20 Danilo 20 Dimas 40 Table Names = {{Gustavo,20},{Danilo,20},{Dimas,40}} Need help to do this.
-3
votes
3 answers

Why segmentation fault in CODE 1?

Code 1: #include #include #include main(int argc,char **argv) { FILE *fp; char lineBuf[100],**p=NULL,temp[100]; int cnt,j,i; if(argc!=2) { puts("ERROR:Invalid no.of arguments"); …
Jhansi Rani
  • 409
  • 1
  • 4
  • 11
-4
votes
3 answers

Reading data from multiple text files

I am new to Java programming, I am trying to print names, read multiple text files from a folder and counting the word frequency of each word file, when i am reading a folder all the text files are printed but they are not read, please look at the…
sum2000
  • 1,285
  • 4
  • 21
  • 34
1 2 3
38
39