file-io

How to load 2D array from a text(csv) file into Octave?

只愿长相守 提交于 2020-01-06 19:54:19
问题 Consider the following text(csv) file: 1, Some text 2, More text 3, Text with comma, more text How to load the data into a 2D array in Octave? The number can go into the first column, and all text to the right of the first comma (including other commas) goes into the second text column. If necessary, I can replace the first comma with a different delimiter character. 回答1: AFAIK you cannot put stings of different size into an array. You need to create a so called cell array. A possible way to

Android NullPointerException when writing to file

非 Y 不嫁゛ 提交于 2020-01-06 15:20:27
问题 I'm getting a NullPointerException when trying to write to a file in the internal storage and I can't figure out why. I read all the documentation and am using that code to test, but no go. I am pulling a string with a HTTP GET request (it's one single line, but in the JSON format) and am trying to write that string into a JSON file in the internal memory. I know the HTTP GET request is working correctly as I was able to log that into the LogCat, but I am stuck on the part where I want to

File not found?

半世苍凉 提交于 2020-01-06 14:22:43
问题 I have an assignment and we have a couple of classes given, one of them is a filereader class, which has a method to read files and it is called with a parameter (String) containing the file path, now i have a couple of .txt files and they're in the same folder as the .java files so i thought i could just pass along file.txt as filepath (like in php, relatively) but that always returns an file not found exception! Seen the fact that the given class should be working correctly and that i

File not found?

大城市里の小女人 提交于 2020-01-06 14:21:56
问题 I have an assignment and we have a couple of classes given, one of them is a filereader class, which has a method to read files and it is called with a parameter (String) containing the file path, now i have a couple of .txt files and they're in the same folder as the .java files so i thought i could just pass along file.txt as filepath (like in php, relatively) but that always returns an file not found exception! Seen the fact that the given class should be working correctly and that i

How do I read in a text file in python 3.3.3 and store it in a variable?

假装没事ソ 提交于 2020-01-06 13:25:30
问题 How do I read in a text file in python 3.3.3 and store it in a variable? I'm struggling with this unicode coming from python 2.x 回答1: Given this file: utf-8: áèíöû This works as you expect ( IFF utf-8 is your default encoding ): with open('/tmp/unicode.txt') as f: variable=f.read() print(variable) It is better to explicitly state your intensions if you are unsure what the default is by using a keyword argument to open: with open('/tmp/unicode.txt', encoding='utf-8') as f: variable=f.read()

Why is FileReader.readAsText() returning null?

时光怂恿深爱的人放手 提交于 2020-01-06 12:42:32
问题 I am trying to read a file in the same directory of an HTML and JavaScript file however it seems to be returning null. Below I have added the code I have from each file. HTML File: <html> <!-- Code to call the Google Maps API and link style.css sheet --> <body> <div class="content"> <div id="googleMap"></div> <div id="right_pane_results">hi</div> <div id="bottom_pane_options"> <button onclick="get_parameters()">Try It</button> </div> </div> </body> <script type="text/javascript" src=".

Segmentation Fault while trying to parse an excel style .CSV file [C programming]

一笑奈何 提交于 2020-01-06 08:16:51
问题 I've been stuck on this project for the better part of the week and while I have been grinding through syntax errors. The gist of the project is to read through the headers and stopping at a certain column and finding certain characteristics like the min, max and average of the column. However, I am having a tough time with memory allocation for this job. I have been unable to further my code so far because I keep getting an error labeled Segmentation Fault: 11 . The bolded section is what I

Reading part of a file in C using fread() and fseek()

大兔子大兔子 提交于 2020-01-06 08:12:46
问题 I'm trying to read a file into a buffer in blocks of size BLOCK_SIZE (currently equal to 1000 unsigned chars ). My code initially finds the number of blocks it will have to read in order to read the entire file (usually 2-4), then iterates through a for loop reading the file (ignore the " +17+filenamesize " stuff, that is all needed for later in the program. However, only on the first time, when j=1 , does it actually put data into the buf array. In other cases, when j != 1 , strlen(buf)

Reading part of a file in C using fread() and fseek()

不羁岁月 提交于 2020-01-06 08:12:25
问题 I'm trying to read a file into a buffer in blocks of size BLOCK_SIZE (currently equal to 1000 unsigned chars ). My code initially finds the number of blocks it will have to read in order to read the entire file (usually 2-4), then iterates through a for loop reading the file (ignore the " +17+filenamesize " stuff, that is all needed for later in the program. However, only on the first time, when j=1 , does it actually put data into the buf array. In other cases, when j != 1 , strlen(buf)

Tomcat deployment file paths (for Java I/O process)

久未见 提交于 2020-01-06 08:03:50
问题 I managed to implement a simple file I/O in my Spring project for files not inside my project (then WAR file) using a .properties file that contains the path (source) and now I need to do it in the server. Before, when I included the files inside the WAR file, I can access them in the Tomcat server using the path /home/my_username/tomcat7/webapps/my_project/WEB-INF/classes/ But now that the files are not inside the WAR file, I just put them adjacent to the webapps folder. The structure of my