I can type in the following code in the terminal, and it works:
for i in range(5):
print(i)
And it will print:
0
1
2
3
4
as expected. However, I tried to write a script that does a similar thing:
print(current_chunk.data)
read_chunk(file, current_chunk)
numVerts, numFaces, numEdges = current_chunk.data
print(current_chunk.da...
I have an application running on Linux, and I find myself wanting windows (!).
The problem is that every 1000 times or so I run into concurrency problems that are consistent with concurrent reading/writing of files. I am fairly sure that this behavior would be prohibited by file locking under Windows, but I don't have any sufficiently f...
Hello, I am trying to use my own function to get the file size from a file. I'll use this to allocate memory for a data structure to hold the information on the file.
The file size function looks like this:
long fileSize(FILE *fp){
long start;
fflush(fp);
rewind(fp);
start = ftell(fp);
return (fseek(fp, 0L, SEEK_END...
In a text file I will have a line containing a series of numbers, with each number separated by a space. How would I read each of these numbers and store all of them in an array?
...
I am trying to read strings from a file that has each string on a new line but I think it reads a newline character once instead of a string and I don't know why. If I'm going about reading strings the wrong way please correct me.
i=0;
F1 = fopen("alg.txt", "r");
F2 = fopen("tul.txt", "w");
if(!feof(F1)) {
do{ //start sc...
I've seen code samples that use an @ before fopen as in
$fh = @fopen($myFile, 'w');
What's the significance of this @?
...
Not sure what could be the problem.
I'm dumping data from an array $theArray into theFile.txt, each array item on a separate line.
$file = fopen("theFile.txt", "w");
foreach ($theArray as $arrayItem){
fwrite($file, $arrayItem . '\n');
}
fclose($file);
Problem is when I open theFile.txt, I see the \n being outputted literally.
A...
Hi All,
I am looking to open a .csv file from the application pack to do some unit testing. So what I would really love is some analog to File.ReadAllText(string path) which is instead X.ReadAllText(Uri uri). I haven't as yet been able to find this.
Does anyone know if it is possible to read text / bytes (don't mind which) from a file ...
Hi,
I want to read in a file line by line, without knowing the line length before. Here's what I got so far:
int ch = getc(file);
int length = 0;
char buffer[4095];
while (ch != '\n' && ch != EOF) {
ch = getc(file);
buffer[length] = ch;
length++;
}
printf("Line length: %d characters.", length);
char newbuffer[length + 1]...
How can I get the current line position of the file pointer?
...
Okay I got this function who prints the name of all files in a directory recursively problem is that it's very slow and it gets the stuff from a network device and with my current code it has to access the device time after time.
What I would want is to first load all the files from the directory recursively and then after that go throu...
Is there a way to prepend a line to the File in Java, without creating a temporary file, and writing the needed content to it?
...
Hi everyone!
PHP question (new to PHP after 10 years of Perl, arrggghhh!).
I have a 100mb file that I want to send to another server.
I have managed to read the file in and "post" it without curl (cannot use curl for this app). Everything is working fine on smaller files.
However, with the larger files, PHP complains about not being...
My application uses lseek() to seek the desired position to write data.
The file is successfully opened using open() and my application was able to use lseek() and write() lots of times.
At a given time, for some users and not easily reproducable, lseek() returns -1 with an errno of 9. File is not closed before this and the filehandle (...
Is this safe to do? (does fgets terminate the buffer with null) or should I be setting the 20th byte to null after the call to fgets before i call clean.
// strip new lines
void clean(char *data)
{
while (*data)
{
if (*data == '\n' || *data == '\r') *data = '\0';
data++;
}
}
// for this, assume that the file...
I'm using the following code to serve uploaded files from a login secured view in a django app.
Do you think that there is a security vulnerability in this code? I'm a bit concerned about that the user could place arbitrary strings in the url after the upload/ and this is directly mapped to the local filesystem.
Actually I don't think...
I am writing a serial communication program in userspace. I want to check how much of the buffer is full. Is there a way to do it using linux terminal i/o api?
Thanks
...
I'm trying to save a file in a subdirectory in Android 1.5.
I can successfully create a directory using
_context.GetFileStreamPath("foo").mkdir();
(_context is the Activity where I start the execution of saving the file) but then if I try to create a file in foo/ by
_context.GetFileStreamPath("foo/bar.txt");
I get a exception sayin...
I'm trying to parse the output from a tool into a data structure but I'm having some difficulty getting things right. The file looks like this:
Fruits
Apple
Auxiliary
Core
Extras
Banana
Something
Coconut
Vegetables
Eggplant
Rutabaga
You can see that top-level items are indented by one space, and it...
I'm working on a parser in php which is designed to extract MySQL records out of a text file. A particular line might begin with a string corresponding to which table the records (rows) need to be inserted into, followed by the records themselves. The records are delimited by a backslash and the fields (columns) are separated by commas. ...