FAQ Database Discussion Community


Python - Select specific value from test file

python,file,text
I'm absolute beginner in python, and I'd like to get field i.e. from 2nd column, 3rd row from text file like this: 176a AUGCACGUACGUA ACGUA AGUCU 156b GACUACAUGCAUG GCAUA AGCUA 172e AGCUCAGCUAGGC CGAGA CGACU (text is separated by spaces). is there any simple way to do that?...

How to save number of times a user has tapped on a view

android,file,local-storage
I am designing a simple application that will count how many times a user has tapped on a imageView. My question is what would be the best way of saving and reading this file. Any suggestions? I am thinking something like using Parse.com's local database. I have tried it, but...

Python - Deleting the first 2 lines of a string

python,string,file,parsing,lines
I've searched many threads here on removing the first two lines of a string but I can't seem to get it to work with every solution I've tried. Here is what my string looks like: version 1.00 6992 [-4.32063, -9.1198, -106.59][0.00064, 0.99993, -0.01210][etc...] I want to remove the first two...

File security System in java? [on hold]

java,file,security,encryption
i'm new to java world.I have a idea about file secure system.When i add a file to the application it will encrypt and store a folder in the installation path.If i need to see the file ,i need to login with my username and password and the file will automatically...

How to make new line when using echo to write a file in C

c,linux,file,echo,system
hi ı am triying to take the data of files in a folder with system function this is the code char path[100],command[120]; scanf("%s",&path); sprintf(command,"echo $(ls %s) > something.txt",path); system(command); but when I look to the something.txt there is no new line. This is the output, all on one line with...

Getting HTTP 302 when downloading file in Java using Apache Commons

java,file,url,apache-commons,fileutils
I am using the following method to download a file off the internet: try { URL url = new URL("http://search.maven.org/remotecontent?filepath=com/cedarsoftware/json-io/4.0.0/json-io-4.0.0.jar"); FileUtils.copyURLToFile(url, new File(jsonerFolder.getParent() + "\\mods\\json-io-4.0.0.jar")); } catch (Exception e1) { logger.error("Downloading json-io failed with an exception"); e1.printStackTrace(); } But the downloaded file is not a jar, rather, it is an...

How to remove numbers from extensions from files

file,shell,rename
I have many files in a directory having extension like .text(2) and .text(1). I want to remove the numbers from extension and output should be like .text and .text . can anyone please help me with the shell script for that? I am using centOs.

File association using CMD

file,cmd,associations
What are ways to associate file from cmd? For example,I want .txt file extension to associate with a typical program, through command prompt? what is the correct file association cmd command?

Android contact image placeholder in listview

android,file,uri,contacts,android-contacts
I have an activity with a listview and a custom adapter. Retrieving the contact information and the image is not the problem. I can not display an alternative image if there is not one for the contact. Checking if the URI is NULL does not work for me. I am...

What is wrong with the function strtok()?

c,arrays,string,file,dynamic-memory-allocation
So, how it works? I've the following block of code; for (i = 0; i < N; ++i){ array[i] = malloc(M * sizeof(char)); fgets(buffer, M-1, fp); array[i] = strtok(buffer, "\n"); } If I execute printf("%s", array[i]); inside the for the strtok() works as I expected, but if I do for...

Saying there are 0 arguments when I have 2? Trying to open a CSV file to write into

ruby,file,csv,dir
I'm trying to read from a CSV file and codify people into groups using an equation. I append the name of their group they fall into to the end of the array that their row creates. Then I write it to a new file so I don't overwrite the original...

Buffered Reader read text until character

java,file,while-loop,bufferedreader,readline
I am using a buffered reader to read in a file filled with lines of information. Some of the longer lines of text extend to be more than one line so the buffered views them as a new line. Each line ends with ';' symbol. So I was wondering if...

Reading an external txt file on main.class

java,file,stream,external
I have a litlle question that, I have a blank main class, and the thing is that I want to know how can I read a external .txt file located on the package of main.java (testes package has main.java and LerDaqui.txt) and I want to know how can I read...

How to find length of all .csv files in directory?

vba,file,csv
I have multiple .csv files that I need to find the length of in my directory. (The number of rows that have data in them.) I'm running the following code from a .xlsx file in the same directory. (I intend to copy data from the .csv files to the .xlsx...

String Pattern Matching Algorithm Used in Different Applications [on hold]

arrays,string,algorithm,file,data-structures
I want to know which algorithm is used by the following Applications or WebSite for String Pattern Matching, I have already search by title but nothing found, i want to learn and understand the real time implementation of String Pattern Matching algorithm used by various Applications. 1.Notepad 2.Adobe Reader...

Android - How can i create a “black list” for the files of my application

android,file,blacklist
In my app i have many files (images and audio files). There is a way i can "mark" this files so that they cannot be read from other app like music player for the audio and gallery for the images? My question is: i can create a sort of "black...

How does one rename multiple files within folders using python?

python,file,python-3.x,rename,file-rename
I have over 1000 folders in 'my documents'. In each folder there are only 4 photos that need to be named to 'North' 'East' 'South' and 'West' in that order. Currently they are named DSC_XXXX. I have written this script but it is not executing. import sys, os folder_list =...

Is there a way to output file size on disk in batch?

file,batch-file,filesize
Is there a way to get the size on disk of a file like in the properties window: I have tried: (inside a batch file) echo %~z1 , for %i in (TestFile.txt) do echo %~zi , dir But they only return the size of the file(s). Is there any way...

How to upload file in PHP and store information in SQLi database?

php,file,mysqli,upload
So I'm trying to do this file upload, and store information such as the size of the file, name, and URL of it in a database, while having the file just upload to a folder on my computer (for testing purposes). It's uploading no problem, the only issue I'm having...

Insert string at line number nodejs

javascript,node.js,file
I have a file that I would like to modify. Is there a way to insert a string to a file at a specific line number? with NodeJS I really thank you for helping me out...

Appending lines for existing file in python [duplicate]

python,file,python-2.7,io
This question already has an answer here: How do you append to a file in Python? 6 answers I want to add lines to an existing file in python. I wrote the following two files print_lines.py while True: curr_file = open('myfile',r) lines = curr_file.readlines() for line in lines: print...

Realm.io Removing the realm file

ios,file,realm
My question, how can I properly remove a realm file? Currently I'm doing so using the file manager, which is fine for me since the Realm file is mostly here for offline caching. My app logs in to a web-platform, and creates a realm for this platform so you can...

C - Reading from a file

c,file,fgetc
I have a text file containing the following: ANT. Small insect, sometimes has wings on its back. BEAR. Large beast. I have a c program: int main(void) { FILE *fp; int c; fp = fopen("myfile.txt","r"); if(fp == NULL) { perror("Error in opening file"); return(-1); } do { c = fgetc(fp);...

Reading a remote text file line by line and comparing with inputbox entry

c#,file
I wrote an application with an inputbox where I want people to input password which will be compared from a list of passwords stored in my webserver in a text file which are one entry in each line then given access to my application So in a few words i...

Python3 string and hmac auth

string,file,python-3.x
I made a pice of code that works, where they key and secret are declared in the code such: key = 'ewjewej2j020e2' secret = 'dw8d8d8ddh8h8hfehf0fh' Then do my business and works. But if i put key and secret in an external file in two lines separated by a newline carrier...

Reading a text file with Tabs

c#,asp.net,.net,file,readfile
In a text file I use TAB to create a column-like grid, but apparently those tabs are just read as spaces, which of course breaks the formatting. This is my code (path is the file path, e.g. D:/folder/testtt.txt): if (File.Exists(path)) { using (TextReader tr = new StreamReader(path)) { while (tr.Peek()...

introduce c++ into html

html,c++,file,class
So I need to create a data base of a student and his marks in class. I did it by using massive Arrays of objects, but I need to write it in html file like a table, and I create special function save. #include <iostream> #include "windows.h" #include <fstream> #include...

How to append a line in a file or before encountering newline character?

java,file
Input File: Online_system_id bank_details payee credit_limit loan_amount Online_system_id bank_details payee credit_limit loan_amount Expected Output: Online_syatem_id bank_details payee credit_limit loan_amount proc_online_system_id Online_syatem_id bank_details payee credit_limit loan_amount proc_online_system_id Below is the code given for reference. I want to add a line after each record i.e before encountering the blank line. What changes...

Java dir/files list

java,file,dir
I am trying to list all directories and files within a certain directory, but while "D:\data" works, "D:\" doesn't. "D" is a secondary disk. This is the exception: Exception in thread "main" java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:203) at java.util.Arrays$ArrayList.<init>(Arrays.java:3813) at java.util.Arrays.asList(Arrays.java:3800) at project.1.scavenger.listf(scavenger.java:19) at project.1.scavenger.listf(scavenger.java:30) at project.1.scavenger.listf(scavenger.java:30) at...

How to test existence of 'file' that cannot be accessed?

c,file
I have a full path stored in char full_path[1000] and I'd like to know whether anything exists at that location. (The next thing my code would do after this check is create something at that location, but I want it to count as an error if there is already something...

How do I let the user name the output.txt file in my C program?

c,file
How to I give the user the ability to name the output .txt file? Here is all I have right now. FILE *f = fopen("output.txt", "a"); ...

Why is my linked list only printing last entry?

c,file,linked-list
Im trying to read specific lines from a file and add it to a linked list and then print it out. Code bellow : #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct list { int uid; char* uname; struct list* next; }node; void push(node ** head, int uid ,char* uname)...

Scala: load different files by input

file,scala,input
My program has a lot of different functions and one of these is the command "load". As soon as the user types as input "load" he can load in a txt file... The problem is, that my command is not only the "load" word itself, its for example "load numbers.txt"...

Why I can't print the content of this StringBuffer object after that I have append into it the lines of a readed file?

java,string,file,stringbuffer
I have the following problem. I have create a method that read a very big textual file starting by its path. The file is read line by line and each line is appended into a StringBuffer. This is my code: public void run(Vector parametri) { if (parametri != null &&...

Add up numbers in files

java,file,add
I have a directory with a lot of files (~40,000), and each file has exactly two lines, each with a number. I want to add up all of the numbers in the entire directory; how do I do that fast and efficiently? I tried this, but it doesn't work, and...

Does FileShare.None make threads wait until the filestream is closed

c#,.net,file,thread-safety
When using a file stream, and setting FileShare to none, and say two users accessing the same function at the same time want to read/write to that file. Will FileShare.None make the second users request waiting or will the second user's request throw an exception? //two users get to this...

FileReader: reading many files with javascript without memory leaks

javascript,file
In a web page, I have to read a small part of a file, this for many (1500 - 12000) small files each being approx 1 Mb big. Once I collected the information I need, I push it back to the server. My problem: I use the FileReader API, garbage...

Strings vs binary for storing variables inside the file format

c++,file,hdf5,dataformat
We aim at using HDF5 for our data format. HDF5 has been selected because it is a hierarchical filesystem-like cross-platform data format and it supports large amounts of data. The file will contain arrays and some parameters. The question is about how to store the parameters (which are not made...

Rust: Lifetime of String from file [duplicate]

file,io,rust
This question already has an answer here: Return local String as slice 1 answer I'm trying to read in some external GLSL code into Rust. The reading works properly, but I run into a lifetime issue in the final expression (in the Ok(_) branch) error: s does not live...

loop for file location until file exists in bash

bash,file,loops,while-loop,echo
I have created this function: function promptFile() { while true; do read -p "Please provide a full path [q to quit]: " file if [ $file == q ]; then echo "Exiting.." return 1 fi if [ ! -f $file ]; then echo "File does not exist, please try again"...

Storing columns on disk and reading rows

c++,file,matrix,io
So I have a C++ code that finds the inverse of a square matrix. The inverse is full and it would be bad to keep it all in memory because I am working with hundreds of thousands of columns. My code generates the columns one by one. After finding the...

How to properly use fscanf to store only the needed information in an array?

c,arrays,file,fscanf
I'm trying to write a program in c that reads a mtx file (mtx stands for midi to text, it's actually a txt file) and stores only the information I need (specifically only the note-on/off and pitch-bend messages) here's an example: the information that I need are: the timing (first...

Delphi - Use a string variable's name in assignfile()

file,delphi,variables,assign
Is it possible to use a variable in the assignfile command? Eg. f : Textfile ; sFile : string ; {contains 'MyFile.txt' as content} ... cFileDir = 'C:\Users\User\Desktop\Data Engine\Data\Country' ; ... Assignfile(f, cFileDir + '\' + sFile) ; ... I appreciate your help very much. if it's unclear I'll edit...

ValueError: dictionary update sequence element #0 has length 1; 2 is required while reading from file

python,file,dictionary
I'm trying to read a dictionary off a file and then make the string into a dictionary. I have this, with open("../resources/enemyStats.txt", "r") as stats: for line in stats: if self.kind in line: line = line.replace(self.kind + " ", "") line = dict(line) return line and the line in the...

Loop for reading txt file with multiple headers and detail items in php [closed]

php,file,header,flat
I have the following incoming txt file: H header1 yyyy I detailofheader1 I detailofheader1 H header2 xxxx I detailofheader2 I detailofheader2 And the following code: $action = substr($line_of_text, 0, 1); if (($action == 'H') ) { //STORE IN VARIABLES ; } if (($action == 'I') ) { //store in variables...

Searching for a sentence in a file java [closed]

java,file,search
I am really stuck up with this. I am having an input file say input.txt. content of input.txt is Using a musical analogy, hardware is like a musical instrument and software is like the notes played on that instrument. Now I want to search the text like a musical instrument...

While appending to file if condition always fails

java,string,file
Input: bank_details payee online_system_id transaction_id pass_num prev_tran_approved bank_details payee online_system_id transaction_id prev_tran_approved Actual output of below code. bank_details payee online_system_id transaction_id pass_num prev_tran_approved online_system_id proc_online_system_id tran_reversed prev_tran_approved bank_details payee online_system_id transaction_id prev_tran_approved online_system_id proc_online_system_id tran_reversed prev_tran_approved Expected Output: bank_details payee online_system_id...

Storing multiple columns of data from a file in a variable

bash,file
I'm trying to read from a file the data that it contains and get 2 important pieces of data from the file and us it in a bash script. A string and then a number for example: Box 12 Toy 85 Dog 13 Bottle 22 I was thinking I could...

How to convert a file name when using Java Mail API

java,file,email
I wrote an adapter between an SQL database and mail server. I used a POP3 connection. Thereafter, I encountered the following problem - when the adapter receives a Russian file name this error occurs. Example input file name: =?UTF-8?B?0KHQutGA0LjQv9C60LAg0JzQsNGA0LjRjy5kb2N4?= The coded format is Base64. I tried to convert Base64 to...

Application of sed command several times on a file

bash,file,sed,process,command
I want to apply several times this sed command to a file: sed '1~2d' file.txt>file1.txt let's say I want to do it 4 times, is there a way to do this process getting also the intermediate files? Thank you in advance Best Regards (The files are 1m UTM coordinates and...

How to Write to a Certain Line in a File in VB

vb.net,file,file-access
I know how to write to a file, however, I want to be able to write to a certain line. I have a large csv file which has many lines. I can only write to the last line (using the writeline) but I really want to write to line x...

Check docx is corrupted or not

c#,file,openxml
I tried many solution but code is always checking corrupted file and send true using (FileStream fileStream = File.OpenRead(path[0])) { MemoryStream memStream = new MemoryStream(); memStream.SetLength(fileStream.Length); fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;...

fast conversion of a text file to arrays C++

c++,arrays,string,file,large-data
I've been working on a project that involves large heightmaps (3000x3000 ~60MB). . What i need to do is to split the data into several 200x200 arrays (15x15 of them), then save them separately (but this time in a format which is as fast as possible to load again). I've...

Am I allowed to use the .ttf format without paying licence fees?

file,fonts,true-type-fonts,legal,fees
The question is if I am allowed to use a .ttf file for any kind of program (including commercial ones). I am not asking about open ttf-loaders like freetype of if I am allowed to use a specific ttf-font. I am asking about the file format (.ttf) itself. And if...

HTML read local file not selected by user

javascript,html,file
I am trying to update a number on a website from a file on my computer that will be changing. Is there a way to read this local file using html/javascript so that I can update the website. Most things I have found give examples of where the user uploads...

Why it is not suggested to pass hardcoded absolute path name to File object constructor File(String)

java,file,constructor,static-analysis,hardcoded
I am creating a File object in Java using File(String pathName), where pathName is the absolute path to the file. While this works perfectly fine from functionality point of view, but it frequently ends up as an static analysis defect. Is there any specific reason why it is suggested to...

File not Uploading using Ajax in cakephp

php,jquery,ajax,file,cakephp
Am trying to upload an image using Ajax to server. I know the code to upload file using Cakephp, but first i just want to make sure that data/file is uploaded to server for sure by printing the formdata. But it seems that only the data i typed in the...

Get string (file name) of a given extension from within a text file

c#,string,file,text
I apologize if the question title is a little confusing, but let's say a text file contains the following data: Sample 'Line1 1 'Line2 2 'ProjectCount FileA.ext 'Projects( 1) 0 'SortTermCount FileB.ext 'Projects( 2) 0 'SortTermCount ... I know the extension name that exists as a string within the file...

Assign hash to array

arrays,ruby,file,hash
My goal is create a hash that stores values from an array as the keys and gets values from another array as the values. I would like to relate "i" value from one array to "i" value from another array. My first array stores the name of files and second...

Reading file with fgets() leaves new line character at the end of each line

php,file,explode
When I explode the lines of a .csv file with a tab as delimiter, like such: // $handle = some TSV file while (($line = fgets($handle)) !== false) { $fields = explode("\t",$line); } If the last column of the row is empty (or maybe even if it isn't), for some...

Using Python, I want to parse each file in one directory with format YY-MM-DD.CSV but ignore all others

python,regex,file,filter
I'm new to Python, so my example represents the mess one aggregates when all experiments so far have failed. #!/usr/bin/python import glob import os import re path = '/home2/SunnyDataBackup/currentGenerated/SBEAM/' files = '[1][0-9]-[0-1][0-9]-[0-3][0-9].CSV$' #if I use '*.CSV', it works but doesn't filter the files fullpath = os.path.join(path, files) print fullpath #fullpathC...

Python is returning false to “1”==“1”. Any ideas why?

python,string,file,integer,logic
I've written a scout system for my A Level computing task. The program is designed to store information on scouts at a scout hut, including badges, have a leaderboard system, and a management system for adding/finding/deleting scouts from the list. The scout information MUST be stored in a file. File...

KeyError while executing Python Code

python,file,csv
I am getting below keyError while running my python script which import data from one csv,modify it and write to another csv. Code snippet: import csv Ty = 'testy' Tx = 'testx' ifile = csv.DictReader(open('test.csv')) cdata = [x for x in ifile] for row in cdata: row['Test'] = row.pop(Ty) Error...

JOptionPane Message with File Path

java,swing,file,path,joptionpane
Is there a way to put a filepath into a JOptionPane? E.g. I have a folder in my project directory and would like to get the path to that folder and show it into the message....

Group all lines with the same word in first column in csv

php,file,csv
I have two columns in my csv file: first_column and second_column. I would like to group all the rows in second column into one string separated by "," if they all have the same word in the first column then output them into a text file. first_column second_column a Chris...

How to have ImageIO.write create a folder path as needed

java,file,filepath,javax.imageio
I have the following code: String nameAndPath = "C:\\example\\folder\\filename.png"; BufferedImage image = addInfoToScreenshot(); //this method works fine and returns a BufferedImage ImageIO.write(image, "png", new File(nameAndPath)); Now, the path C:\example\folder\ does NOT exist, so I get an exception thrown with message: (The system cannot find the path specified) How can I...

Append a line to file when blank line appears

java,string,file
Input: apple banana grapes apple banana grapes apple banana grapes Expected Output: apple banana grapes orange melon apple banana grapes orange melon apple banana grapes orange melon Code: String newLine=null; PrintStream output = new PrintStream(outputFile); BufferedReader br = new BufferedReader(new FileReader(outputFile)); while((newLine=br.readLine())!=null && !newLine.isEmpty()){ if(!newLine.contains("orange")){ output.println("orange"); } if(!newLine.contains("melon")){ output.println("orange"); }...

how to save information from a file in java

java,string,file,io
I am supoose to read a file lets say it has 3 lines: 2 Berlin 0 2 2 10000 300 Nilreb 0 2 2 10000 300 the first integer number shows how many names(lines) i have. the 2nd and 3rd lines show information about two post offices. them i am...

Check if file exists using Apache Commons VFS2

java,file,sftp,apache-commons-vfs
I would like to ask if there is a way how to check if file already exists in the folder using only Apache Commons. I have method which uploads into the SFTP folder but it overwrites current files anytime the method is running. The method is set to run every...

Function dup2(int oldfd, int newfd) fails in for() loop

file,strace
I tried this for fun to see if it works but eventually it does not. i = open("something", O_RDWR); for(i ; i<10 ; i++); { if(dup2(i, i+1 ) == -1 ) { printf("Dup failed\n"); exit(1); } } I have straced the executable and the output is this: open("something", O_RDWR) =...

FileNotFoundException EACCES (Permission Denied)

android,file,exception,filenotfoundexception
I'm getting an exception that file open permission is denied when I'm trying to open a FileInputStream. File myFile = new File(Environment.getExternalStorageDirectory() .getAbsolutePath() + "/test/test.txt"); try { FileInputStream inStream = new FileInputStream(myFile); // crash Here's the stacktrace: System.err﹕ java.io.FileNotFoundException: /storage/emulated/0/test/test.txt: open failed: EACCES (Permission denied) System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:456) System.err﹕ at...

Read text file from specific position and store in two arrays

c#,arrays,file,text
I have text file which contains line like this: @relation SMILEfeatures @attribute pcm_LOGenergy_sma_range numeric @attribute pcm_LOGenergy_sma_maxPos numeric @attribute pcm_LOGenergy_sma_minPos numeric... Where are about 6000 lines of these attributes, after attributes where are lines like this: @data 1.283827e+01,3.800000e+01,2.000000e+00,5.331364e+00 1.850000e+02,4.054457e+01,4.500000e+01,3.200000e+01... I need to seperate these strings in two different arrays. So far...

javscript readstream line by line

javascript,file,csv,io
I'm trying to read in a CSV file line by line and add each line to an array, my code so far is: var csvFile = 'Domain.csv'; var fs = require('fs'); var readableStream = fs.createReadStream(csvFile); var data = ''; readableStream.on('data', function(chunk) { var temp = ''; temp = chunk; global.qArray.push(temp);...

Read and Write the specific content

python,file
I am trying to read specific content of a file1.txt and write this specific content in another file file2.txt. The problem is I read entire part after Bar where I want to read only the line start with [x] and only with the Bar section. Source Code def read_write_file_content(): data_file...

Python3 create files from dictionary

file,python-3.x,dictionary
I have a dictionary in a function which is called searchInMyDict(dict) for example. The dictionary included in that function has for key a group name and has for value a list of gene's functions. the dictionary looks like : {"OG_1": ["gene's functionA, gene's functionB, gene's functionC"] "OG_2": ["gene's functionM, gene's...

How to Upload file onclick of button of type=button not type=submit in mvc4 using html begin form

file,asp.net-mvc-4,button,upload,submit
I have to upload a file using a button (of type button, not submit). And I want to show popup when no-file is selected and clicked on upload, it should not go to controller action. Can anyone help please?...

Open file under cursor declared as #include in the C/C++ code in Vim?

file,vim
I now how I can open a file under cursor in Vim. Is there any way to also open files declared like below? #include <iostream> #include "limits.h" ...

File is not being downloaded when requested through Ajax using JQuery

javascript,jquery,ajax,file,csv
I need to download a .CSV file with certain information from a website, so I'm using a link and some Javascript/JQuery to get the table from the servr and create the file. I have this link that is supposed to download the file when clicked: <a class="areaSummaryExport" value="1">...</a> And then...

How can I create a PNG image file from a list of pixel values in Python?

python,image,list,file,python-imaging-library
I can generate a list of pixel values from an existing image file using a procedure like the following: from PIL import Image image = Image.open("test.png") pixels = list(image.getdata()) width, height = image.size pixels = [pixels[i * width:(i + 1) * width] for i in xrange(height)] How could I convert...

Downloading file from Java servlet gives null

java,file,servlets,stream
I am trying to create a method that allows users to download a file on the file system via a Servlet. Right now, the correct filename shows on the download and a file is downloaded but the contents of the file are always null. I've also tried to get the...

Group instances based on NA values in r

r,file,csv,instance,na
I am reading a csv file and unfortunately my dataframe has many missing values. A small snip is as following: df <- data.frame(Size= c(800, 850, 1100, 1200, 1000), Value= c(900, NA, 1300, 1100, NA), Location= c(NA, 'midcity', 'uptown', NA, 'Lakeview'), Num1 = c(2, NA, 3, 2, NA), Num2 = c(2,3,3,1,2),...

Redirect output to 'file' command

file,ar
Is there any way to have the file command get it's input from stdin? Specifically, I am trying to get the file type of a file in an archive, and am trying to do it in a single command. I tried this: ar -p foo.a baz.o | file but that...

Changing file name to the user's name PHP

php,file,upload
Instead of the file name being what the users want to name it, I would like the file name to be the user's username. As you can see in the code below, I got the user's username from the session. Now, I would just like to apply it to $_FILES,...

Java BufferedReader - empty line issue

java,file,javafx,line,bufferedreader
Problem description: For example we have a text file file.txt with following content: Hello(LS) what(LS) are(LS) <empty_line>(LS) you(LS) doing(LS) <empty_line>(LS) <empty_line>(LS) now(LS) <empty_line>(LS) <empty_line>(LS) <empty_line>(EOF) (LS - line separator, EOF - end of file) If I understood the idea of text file, the file is looking something like that. Now,...

C++ reading and editing files

c++,file
I have a program in C++ that only asks the maths, physics, and P.E and saves in file and dat files is also the average of those values... so far so good but what I need now is that in can ask the user if he wants to check/visualize what...

ERROR: variable “string” is not initialized

c,arrays,string,file
I wrote this code that reads from a .txt a string and settles it in a char *, but it gives me error that the variable "string" is not initialized, even if i initialized it inside the fscanf, can u tell me where i wrong? Thanks! char *string; FILE *fp...

How would I read a text file in C?

c,file,fread
I have file.txt with 123456 2,00 beer 234567 2,50 milk 345678 3,30 ice cream I want to put this info in my dynamic two-dimensional array: char **dataBase; dataBase = (char**)malloc(NUM_OF_PROD * sizeof(char*)); for(i = 0; i < NUM_OF_PROD; i++){ dataBase[i] = (char*)malloc(MAX_BUFFER* sizeof(char)); } But I don't know how. We...

IllegalStateException: Iterator already obtained [duplicate]

java,file,loops,path
This question already has an answer here: java.lang.IllegalStateException: Iterator already obtained 1 answer so I wrote a little Java program to test a little stack language I made vie various test file, but for some reason it won't work. Here is the code: import org.apache.commons.io.FilenameUtils; import java.io.IOException; import java.nio.file.*;...

How to get rid of .ignore file in Git?

git,file,bitbucket,ignore
I have create an ignore file , the list included .jar files . I then merged my branch to a development branch and even though I had resolved all my conflicts , I still had a lot of errors. Most of them had something to do with support.v4 (the import...

How to know fast if another computer is accesible in AS3 (Adobe Air)

file,actionscript-3,air,lan
I'm using FileStream to read files in two computers that are connected in a Local Area Network (LAN). I have no problem to read the files when the others computers are connected. I'm checking if the directory exists before writing the file I'm checking if the directory AND the file...

Python algorithm error when trying to find the next largest value

python,algorithm,file,output
I've written an algorithm that scans through a file of "ID's" and compares that value with the value of an integer i (I've converted the integer to a string for comparison, and i've trimmed the "\n" prefix from the line). The algorithm compares these values for each line in the...

Read words/phrases from a file, make distinct, and write out to another file, in Java

java,file,sorting,distinct-values
I have a text file with a word or phrase on each line. How do I: Read those phrases into memory, Make distinct (eliminate duplicates), Sort alphabetically, Write the results back out to a file? StackOverflow has answers for similar Questions in other languages such as C, PHP, Python, Prolog,...

How to add Copyright and Authors info to Images created in PHP?

php,image,file,properties,file-attributes
Is there any way to add Copyright info to the image file created by PHP? To be clearer, you can add copyright info to a file with photoshop, so when you get its properties, you see something similar to: I want to Add/Edit Details info of a file in php....

Encrypting (large) files in PHP with openSSL

php,file,encryption,aes,php-openssl
I'm trying to encrypt (big) files in PHP using AES and have looked into using Mcrypt and OpenSSL, the problem is all solutions I have found so far only encrypt strings, and the files I'm trying to encrypt would trigger the max memory limit for PHP (which unfortunately can't be...

Writing at end of every line in a file in Node.js?

node.js,file
I have a file one two three I want to append a word at the end of every line in this file. How can I achieve that in node ? eg. onecandy twocandy threecandy Then I want to use this file in another function ,i.e after allcandy has been added...

Skip a line using BufferedReader (skip, but not read it)

java,file,file-io,bufferedreader
Hi guys I am currently using BufferedReader to read files. I have something like: br.readLine() != null for each call loop. And now what should I do if I want to skip a line. Here, I've read several similar questions other people posted, most of them suggested using readLine(). I...

Mark a file as created by my app

c#,.net,file,pdf
My application creates some pdf files using some private assemblies and then send them to another app by copying them in the second app folders. After a while I need to come back and get my files and update them, the thing is that meanwhile some other pdf files can...

Why the first byte of .png file is 0x89?

file,png,formats
I am currently reading about PNG file format. It turns out that the first byte of the file is specified to be equal to 0x89. I am wondering what are the reasons of the value of that byte. What I've already learned about the format is that the first byte...

How to change the file name before store in file and database

c#,file
this code is to check does the user has upload any file and the file namd. if (FileUpload1.HasFile) { fileName = FileUpload1.FileName; FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Data/") + fileName); fileLocation = Server.MapPath("~/Data/") + fileName; } I wonder can I add the current date on the end of the file name. my file can be...

how to replace strings in a file by other strings in java

java,string,file,replace
I have a file which every line contains strings like that : usual,proper,complete,1,convenient,convenient,nonprob,recommended,recommend I want to replace every word by such a code like that : 1000, 100, 110, 110, 111, 001, 111, 111, 1000 Here is the code that I used but it still incomplete : public class Codage...