How to save a function as input parameter in python?

I have written a script you could basically reduce to the following: def Readhtml(a,b): read some values from an html file return a list of values def ReadSQL(a,b): Read some values from an SQL Database return a list of values def mainfunction(Variab

Do not check the file size correctly

I wrote a simple script to move movies in my downloads directory, once they are finished downloading, to the location they need to go and have a simple question regarding it. Maybe I'm not understanding how the os module is working to the current siz

File entry containing a string and an integer

I have a file whose content looks like this : Aadam 50 Aadam 0 Aad 0123 Waleed 12345 Now, I need to store first line in a string array and second line into an integer array. This is the source code that I have written.... ifstream infile ("File.txt&q

Unable to open the file using fopen (php)

I am trying to open a file for reading in php script but having trouble. This is my code $fileHandle = fopen("1234_main.csv", "r")or die("Unable to open"); if (!file_exists($fileHandle)) { echo "Cannot find file.";

Python does not write to the file for initial execution

I have a super simple code and when run the first time it does not write to the file. But when run a second/multiple times later it writes to the file. The same thing happens when using "w" instead of "a" as well. It also seems that th

FILE IO, tokenizing a string

im trying to read a comma delimited file, and create tokens by the comma delimeter and printing names. but the names do not print after tokenize. names.csv looks like issac,sanchez anothony,huerta abbie,lynn mark,beasly alyssa,emily my current code #

vbscript code to read text file entry avoiding manual effort

I am drilling down Internet to get Vbscript code, where input is read from text file one per line and pass it to the commands in script. I am just a beginner and need help with this. Basically I am gathering script to get pending patches of servers i

Get ArrayIndexOutOfBound when using line.split on the chain

Getting indexOutOfBound. After sucessfull file save. I open the file to perform the following tasks: find the total costPerItem, totalCount and sum. Don't know why I'm getting out of bound. Error points out to totalCost =+ Double.parseDouble(index[1]

Frequency analysis? Caesar encryption C

I have written this code so far, and now i am required to use the frequency analysis to crack the code which I am not not clear of. From what I understand, I must first count the frequency of letters in a string, then I would say compare it with the

How to read a text file in Pydev?

I'm doing a school assignment that requires me to read a file. I chose to use the Eclipse and Pydev combination because I really like the environment. However, no matter where I place the .txt file I get the following error: FileNotFoundError: [Errno

How to create a file name incremented in Python?

I'm creating a program that will create a file and save it to the directory with the filename sample.xml. Once the file is saved when i try to run the program again it overwrites the old file into the new one because they do have the same file name.

Exporting Files - Strange Characters

I've been asked to replicate a file sent by the following Excel VBA code. The problem is with the export of the data contained within the "for" loop. The quantity ".111" is being written in the export file as "øSã=", ".2

Move Maildir content to the parent directory

i have to change my virtual mail folder tree. I've configured a new mailserver and now i must import my old virtual mailboxes. My old one directory was like /var/spool/vmail/ with inside ( cur / new / ...). I have to move li

How to read a binary file in an unsigned character vector

Lately I've been asked to write a function that reads the binary file into the std::vector<BYTE> where BYTE is an unsigned char. Quite quickly I came with something like this: #include <fstream> #include <vector> typedef unsigned char BY

myFile.exists () does not work logically in Android

I have a section of code that is supposed to check if an mp3 file is stored in the SD card on the MediaStore.Audio.Media content provider the problem is that no matter the situation. Either if the file with the pathname stored in variable "audioFilen

Python () plays the for loop

I tried my best to search for the answer, but couldn't fine something that will suit my needs. I am trying to reformat an XML file into a custom format and running into issues. Here is my requirement. I have the following XML file: <parameters> <

How to perform file I / O in C in Xcode?

I am using Xcode as my IDE for C. #include <stdio.h> int main (int argc, const char * argv[]) { FILE *file; int numberTest = 0; file = fopen("fileTest.dat", "r"); if (file == NULL) { printf("File not found!\n"); } fscan

Write a & ldquo; \ n & rdquo; in a text file

I'm trying to write a string \n in a text file. But the result in the text file is a newline. I know that the \n represents a newline. But in my case, I really need to see the String \n, not the newline. How can I solve this?The \ character escapes t

Writing XML to a file without overwriting previous data

I currently have a C# program that writes data to an XML file in using the .NET Framework. if (textBox1.Text!="" && textBox2.Text != "") { XmlTextWriter Writer = new XmlTextWriter(textXMLFile.Text, null); Writer.WriteStartDocum

Shrinking file that is open in read / write

In perl: I have a file opened in read/write, with an exclusive lock. open( $f, "+< $filename" ); flock( $f, LOCK_EX ); If I write more data to the file than it previously held, the file will grow. If I write less data, my new contents are at

How to delete a non-empty directory in C ++?

In C++, how can I remove a directory with all its contained files? I know there is rmdir, but it will only remove non-empty directories, so how do I list and remove all contained files first? I know it shouldn't be hard using Boost Filesystem, but I

Analyze a file with a hierarchical structure in Python

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