file-io

How to read multiple files into a single cell array?

a 夏天 提交于 2020-01-14 05:44:26
问题 I have a large dataset split into 5 files (each has 15000 attributes, first file contains header (attribute names) and 9999 records, and the other 4 contain 10000 records). Using textscan, I have created 5 cell arrays which have to be merged and don't know whether this approach is appropriate or it would be better to directly read all 5 files into single cell array. Anyway I would be thankful if anyone of you could show the way to merge several cell arrays into single cell array or read

R shiny fileInput large files

你离开我真会死。 提交于 2020-01-14 01:43:29
问题 i have some problem with fileInput for R Shiny. Size limit is set to 5MB per default. Since the files i have to work with are very large (>50GB), I only need the datapath and or name of the file. Unfortunatly fileInput wants to upload the complete file or at least it is loading the file somehow and tells me that the file is too big after i have reached the 5MB limit. How can I only hand over the path to my app without uploading the file? ui.R library(shiny) # Define UI ---- shinyUI(fluidPage(

Android Things filesystem

北城以北 提交于 2020-01-13 20:43:09
问题 I am building this app on android things. I want to be able to give it access to media files on a USB stick or maybe even the raspberry pi's SDcard. I don't know what I'll have it do with those files yet but I just wanna know if its possible. If it isn't that's fine I have other solutions but I figured I would start with the obvious approach first. 回答1: I'm didn't try it, but seems it's possible by the same way as in normal Android OS. To do this You should mount Your USB dongle into the

ifstream.read() vs. ifstream.readsome() in MSVC++7.1

*爱你&永不变心* 提交于 2020-01-13 16:26:26
问题 I just took some older code of a file reader that had been developed under Linux and tried to use that very same code in my Windows project compiled with MSVC++7.1. The code compiled without any problems, but the file seemed to be empty according to the file reader on Windows. I tracked the problem down to ifstream.readsome() that didn't read anything from the file, without setting any error flags on the stream. The code provided below compiles on either Linux and Windows, but Linux it works

ifstream.read() vs. ifstream.readsome() in MSVC++7.1

邮差的信 提交于 2020-01-13 16:25:14
问题 I just took some older code of a file reader that had been developed under Linux and tried to use that very same code in my Windows project compiled with MSVC++7.1. The code compiled without any problems, but the file seemed to be empty according to the file reader on Windows. I tracked the problem down to ifstream.readsome() that didn't read anything from the file, without setting any error flags on the stream. The code provided below compiles on either Linux and Windows, but Linux it works

Skip a line while reading a file in C

妖精的绣舞 提交于 2020-01-13 10:37:50
问题 I have a problem and I haven't found a solution that works. It's really easy, but I don't understand what to do. I have a file with some lines, like: #comment #comment icecream 5 pizza 10 pie 7 #comment tortillas 5 fajitas 5 And I want that my program just read the lines that don't start with # . FILE *pf; char first [20], second [20]; pf = fopen("config.conf", "r"); if (pf) { while (! feof(pf)) { fscanf(pf, "%s \t ", first); while(!strcmp(first,"#")){ `HERE I NEED JUMP TO NEXT LINE` fscanf

Java - Random line read

柔情痞子 提交于 2020-01-13 08:36:27
问题 I am programing an Android app, and would like my program to read a random line of a file. How would I go about doing that? 回答1: To do that, you need either fixed-length lines (the implementation details should be obvious in that case) or information about how many lines there are and (optionally, for better performance) at what offsets inside the file they begin (an index of sorts). For small files, you can create such an index on demand whenever you need a random line. To do it efficiently

Java - Random line read

耗尽温柔 提交于 2020-01-13 08:36:11
问题 I am programing an Android app, and would like my program to read a random line of a file. How would I go about doing that? 回答1: To do that, you need either fixed-length lines (the implementation details should be obvious in that case) or information about how many lines there are and (optionally, for better performance) at what offsets inside the file they begin (an index of sorts). For small files, you can create such an index on demand whenever you need a random line. To do it efficiently

Locking and unlocking files using C API in Ubuntu LInux

大兔子大兔子 提交于 2020-01-13 05:38:46
问题 How can I lock a file for a specified period of time (10 seconds) using the C language in Ubuntu Linux ? 回答1: It works like this: #include <io.h> #include <sys/file.h> ... int f = open ("filename", O_RDONLY); if (f < 0) error(); if (flock (f, LOCK_EX)) error(); sleep (10); if (flock (f, LOCK_UN)) error(); ... 回答2: Use fcntl(2) to lock the file, then use alarm(2) to call your SIGALRM handler which will then unlock it. 来源: https://stackoverflow.com/questions/2058891/locking-and-unlocking-files

Locking and unlocking files using C API in Ubuntu LInux

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-13 05:38:08
问题 How can I lock a file for a specified period of time (10 seconds) using the C language in Ubuntu Linux ? 回答1: It works like this: #include <io.h> #include <sys/file.h> ... int f = open ("filename", O_RDONLY); if (f < 0) error(); if (flock (f, LOCK_EX)) error(); sleep (10); if (flock (f, LOCK_UN)) error(); ... 回答2: Use fcntl(2) to lock the file, then use alarm(2) to call your SIGALRM handler which will then unlock it. 来源: https://stackoverflow.com/questions/2058891/locking-and-unlocking-files