file

How to read in a text file into a vector of a class

萝らか妹 提交于 2021-02-10 07:33:46
问题 I need to read in lines from a given text file into a vector of a class of strings. I have this so far but I cannot get them into the vector. I am trying to create a while loop to read in each line of the text file input by the user. I've modified it from the last time, but all it does is read in one thing at a time, splitting Las and Vegas. I also need to push the information from my text file into my Flight vector. #include "sort.h" #include "flight.h" #include "std_lib_facilities_4.h"

Email notification on file change in particular directory with Python

两盒软妹~` 提交于 2021-02-10 07:32:52
问题 I would like to script a function wich is looking in a particular directory for files, if there are new files, it should send out an notification email. I already prepared a script which is looking for new files in a directory, it write the notification about a new file into the console. But now I would like to notified via email, as soon as there has a new file arrived. Could someone help? import os, time def run(): path_to_watch = "//D$:/testfolder/" print "watching: " + path_to_watch

pandas read_csv. How to ignore delimiter before line break

拜拜、爱过 提交于 2021-02-10 06:38:29
问题 I'm reading a file with numerical values. data = pd.read_csv('data.dat', sep=' ', header=None) In the text file, each row end with a space, So pandas wait for a value that is not there and add a "nan" at the end of each row. For example: 2.343 4.234 is read as: [2.343, 4.234, nan] I can avoid it using , usecols = [0 1] but I would prefer a more general solution 回答1: You can use regular expressions in your sep argument. Instead of specifying the separator to be one space, you can ask it to use

Python Django- How do I get file path from an input file tag in a form?

99封情书 提交于 2021-02-10 06:34:26
问题 I just need the file path. This is what I came with so far: index.html: <form enctype="multipart/form-data" action="{% url 'polls:search_for_match' %}" method="post"> {% csrf_token %} <label for="file_path"></label> <input type="file" class="form-control" id="file_path" name="file_path" > <button type="submit" class="btn btn-default" >Analyze!</button> </form> view.py def searchMatch(request): form_class = Query if request.method == 'POST': form = form_class(request.POST, request.FILES) *

C++ reading binary files

。_饼干妹妹 提交于 2021-02-10 06:08:20
问题 I want to understand how does reading binary files work in C++. My code: int main() { ifstream ifd("input.png",ios::binary |ios::ate); int size = ifd.tellg(); ifd.seekg(0, ios::beg); vector<char> buffer; buffer.reserve(size); ifd.read(buffer.data(), size); cout << buffer.data(); return 0; } I thought that if I cout my buffer I would get the result in binary but that is not the case. My output is: ˙Ř˙á6Exif And if I read the text file it displays the text in normal form not in binary.

C++ reading binary files

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 06:03:23
问题 I want to understand how does reading binary files work in C++. My code: int main() { ifstream ifd("input.png",ios::binary |ios::ate); int size = ifd.tellg(); ifd.seekg(0, ios::beg); vector<char> buffer; buffer.reserve(size); ifd.read(buffer.data(), size); cout << buffer.data(); return 0; } I thought that if I cout my buffer I would get the result in binary but that is not the case. My output is: ˙Ř˙á6Exif And if I read the text file it displays the text in normal form not in binary.

Write to a file until it reaches a certain size

血红的双手。 提交于 2021-02-10 05:27:34
问题 I am writing an XML file for sitemap and Google says that the file cannot be greater than 10MB. I was wondering if there is a way to write to a file until a certain file size is met, then close it and open a new one. I have it so that once it reaches a certain number of entries, it will close file and open a new one. I was using Number::Bytes::Human to try to get the file size with no luck. 回答1: You may use the tell method on a file handle to establish the offset where the next data will be

Write to a file until it reaches a certain size

你说的曾经没有我的故事 提交于 2021-02-10 05:27:28
问题 I am writing an XML file for sitemap and Google says that the file cannot be greater than 10MB. I was wondering if there is a way to write to a file until a certain file size is met, then close it and open a new one. I have it so that once it reaches a certain number of entries, it will close file and open a new one. I was using Number::Bytes::Human to try to get the file size with no luck. 回答1: You may use the tell method on a file handle to establish the offset where the next data will be

How to read chunks for a text file based on a word as a key delimiter?

你说的曾经没有我的故事 提交于 2021-02-08 16:37:12
问题 I have a .txt file with this format: Part #368 - XXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Part #369 - XXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Convert blob to WAV file without loosing data or compressing

一世执手 提交于 2021-02-08 13:58:12
问题 I am working on recording speeches and converting them to downloadable WAV files. I am using Angular6 and MediaRecorder. Firstly I obtain the blob and from the blob, I get the .wav file. The problem is that the WAV file (which can be played and sounds good) loss much of its properties during the process and is not a valid WAV. It keeps being a WebM file. For further processing, I need really valid and high-quality WAV files. In the end, I get files of ~20KB, instead of bigger files of ~300KB.