file-io

declare/open excel file in vb.net

你离开我真会死。 提交于 2020-01-03 02:59:09
问题 I've been trying for a while to declare or to open a excel sheet in vb.net. I already read excel file in vb.net and other links but it doesn't work. I added Microsoft Excel 12.0 Object Library. I included: Imports Microsoft.VisualBasic Imports System.Net.Mime.MediaTypeNames Imports Microsoft.Office.Interop I want to declare / open the excel file in a module: Public Module postleitzahlen_array Dim myarray As String Dim xlApp As Excel.Application xlApp = New Excel.ApplicationClass ' here is the

Reading large (~1GB) data file with C++ sometimes throws bad_alloc, even if I have more than 10GB of RAM available

无人久伴 提交于 2020-01-02 22:01:01
问题 I'm trying to read the data contained in a .dat file with size ~1.1GB. Because I'm doing this on a 16GB RAM machine, I though it would have not be a problem to read the whole file into memory at once, to only after process it. To do this, I employed the slurp function found in this SO answer. The problem is that the code sometimes, but not always, throws a bad_alloc exception. Looking at the task manager I see that there are always at least 10GB of free memory available, so I don't see how

Unable to write to a text file

大兔子大兔子 提交于 2020-01-02 15:26:19
问题 I am running some tests and need to write to a file. When I run the test's the open = (file, 'r+') does not write to the file. The test script is below: class GetDetailsIP(TestGet): def runTest(self): self.category = ['PTZ'] try: # This run's and return's a value result = self.client.service.Get(self.category) mylogfile = open("test.txt", "r+") print >>mylogfile, result result = ("".join(mylogfile.readlines()[2])) result = str(result.split(':')[1].lstrip("//").split("/")[0]) mylogfile.close()

reading data from file in c

烂漫一生 提交于 2020-01-02 13:50:31
问题 I have a txt file named prob which contains: 6 2 8 3 4 98652 914 143 789 1 527 146 85 1 74 8 7 6 3 Each line has 9 chars and there are 9 lines. Since I cant make a string array in c, im be using a two dimensional array. Careful running the code, infinite loops are common and it prints weird output. Im also curious as to where does it stop taking in the string? until newline? expected result for each "save": 6 2 8 3 or watever the line contained. #include <stdio.h> FILE *prob; main() { prob =

OpenText vs ReadLines

浪尽此生 提交于 2020-01-02 10:15:06
问题 I came across an implementation of reading a file line by line that looks like this: using (StreamReader reader = File.OpenText(path)) while (!reader.EndOfStream) { string line = reader.ReadLine(); } However personally I would do just this: foreach (string line in File.ReadLines(path)) { } Is there any reason to pick one over the other? 回答1: Objectively: The first one is picking the line one by one and you do the process as you stream the data. The second one generates IEnumerable<string> at

Is there a limit to the number of file handles I can open in Perl?

孤街浪徒 提交于 2020-01-02 10:08:52
问题 I am setting up a hash reference containing file handles. The fourth column of my input file contains an identifier field that I am using to name the file handle's destination: col1 col2 col3 id-0008 col5 col1 col2 col3 id-0002 col5 col1 col2 col3 id-0001 col5 col1 col2 col3 id-0001 col5 col1 col2 col3 id-0007 col5 ... col1 col2 col3 id-0003 col5 I use GNU core utilities to get a list of the identifiers: $ cut -f4 myFile | sort | uniq id-0001 id-0002 ... There can be more than 1024 unique

Procedure to open, write and append in Ada

半城伤御伤魂 提交于 2020-01-02 10:00:43
问题 This question is a follow-up of the post at Ada file operation: instantiation and exception about writing to files in Ada. I chose to place this question in a separate post so that it'll become visible to more people as I already accepted an answer on a slightly different issue (which was on exceptions in file handling) in that aforementioned post. WITH Ada.Sequential_IO; WITH Ada.Float_Text_IO; PROCEDURE TEST is package Seq_Float_IO is new Ada.Sequential_IO (Element_Type => Float); X_File :

Python binary file reading problem

被刻印的时光 ゝ 提交于 2020-01-02 08:33:21
问题 I'm trying to read a binary file (which represents a matrix in Matlab) in Python. But I am having trouble reading the file and converting the bytes to the correct values. The binary file consists of a sequence of 4-byte numbers. The first two numbers are the number of rows and columns respectively. My friend gave me a Matlab function he wrote that does this using fwrite. I would like to do something like this: f = open(filename, 'rb') rows = f.read(4) cols = f.read(4) m = [[0 for c in cols]

How to lock a file

旧时模样 提交于 2020-01-02 06:07:58
问题 I have a write method that is supposed to safely write data to a file. // The current file I am writing to. FileOutputStream file = null; ... // Synchronized version. private void write(byte[] bytes) { if (file != null && file.getChannel() != null) { try { boolean written = false; do { try { // Lock it! FileLock lock = file.getChannel().lock(); try { // Write the bytes. file.write(bytes); written = true; } finally { // Release the lock. lock.release(); } } catch (OverlappingFileLockException

Finding bogus data in a pandas dataframe read with read_fwf()

孤人 提交于 2020-01-02 05:24:11
问题 I'm trying to analyse the weather records for New York, using the daily data taken from here: http://cdiac.ornl.gov/epubs/ndp/ushcn/daily_doc.html I'm loading the data with: tf = pandas.read_fwf(io.open('state30_NY.txt'), widths=widths, names=names, na_values=['-9999']) Where: >>> widths [6, 4, 2, 4, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5,