Menu
  • HOME
  • TAGS

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

android,file,blacklist

I solved my problem by inserting my files in a folder named like this: ".my_folder" and it's worked!

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

@using(Html.BeginForm("Upload","Home",new {@id="frm"})) { <input type="file" id="upld" /> <input type="button" value="upload" id="btn" /> } <script> $('#btn').click(function(){ var has_selected_file = $('#upld').filter(function(){ return $.trim(this.value) != '' }).length > 0 ; if(has_selected_file){ $('#frm').submit(); } else{ alert('No file selected'); } }); I hope this is your requirement ...

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

java,file,file-io,bufferedreader

If you care about the memory wasted in the intermediate StringBuffer, you can try the following implementation: public static void skipLine(BufferedReader br) throws IOException { while(true) { int c = br.read(); if(c == -1 || c == '\n') return; if(c == '\r') { br.mark(1); c = br.read(); if(c != '\n')...

Python algorithm error when trying to find the next largest value

python,algorithm,file,output

I think your program is failing because you need to change: _getAvailableID(i) to return _getAvailableID(i) (At the moment the recursive function finds the correct answer which is discarded.) However, it would probably be better to simply put all the ids you have seen into a set to make the program...

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

c#,file

According to your loop, once you get line that doesn't equals input, then you stop everything - what is logically incorrect. You have to compare lines, until one of them equals input or end of file. ... bool valid = false; using (WebClient client = new WebClient()) { using (Stream...

Storing multiple columns of data from a file in a variable

bash,file

Example code: #!/bin/bash declare -a textarr numarr while read -r text num;do textarr+=("$text") numarr+=("$num") done <file echo ${textarr[1]} ${numarr[1]} #will print Toy 85 data are stored into two array variables: textarr numarr. You can access each one of them using index ${textarr[$index]} or all of them at once with ${textarr[@]}...

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

ruby,file,csv,dir

I believe the problem is with Dir.foreach, not CSV.open. You need to supply a directory to foreach as an argument. That's why you are getting the missing argument error. Try: Dir.foreach('/path/to_my/directory') do |current_file| I think the open that is referenced in the error message is when Dir is trying to...

Application of sed command several times on a file

bash,file,sed,process,command

It SOUNDS like what you need is (replace 6 and 2 with whatever numbers you want): awk '{for (i=2;i<=6;i+=2) if (!(NR%i)) print > ("file"i)}' file e.g. run in an empty directory: $ seq 1 20 | awk '{for (i=2;i<=6;i+=2) if (!(NR%i)) print > ("file"i)}' $ lf file2 file4 file6 $...

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

java,file,sorting,distinct-values

You can leverage: NIO (Non-blocking I/O) API (available since Java 7) Streams API (available since Java 8) …to solve the problem elegantly: public static void main(String... args) { Path input = Paths.get("/Users/yourUser/yourInputFile.txt"); Path output = Paths.get("/Users/yourUser/yourOutputFile.txt"); try { List<String> words = getDistinctSortedWords(input); Files.write(output, words, UTF_8); } catch (IOException e) {...

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

file,batch-file,filesize

Interesting question. I'm not aware of the size on disk value being a property of any scriptable object. You could calculate it by getting filesize modulo bytes-per-cluster, subtracting that modulo from the file size, then adding the cluster size. (Edit: or use Aacini's more efficient calculation, which I'm still trying...

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

java,file,filepath,javax.imageio

you have to create the missing directories yourself If you don't want to use a 3rd party library you can use File.mkdirs() on the parent directory of the output file File outputFile = new File(nameAndPath); outputFile.getParentFile().mkdirs(); ImageIO.write(image, "png", outputFile); Warning that getParentFile() may return null if the output file is...

Buffered Reader read text until character

java,file,while-loop,bufferedreader,readline

It would be much easier to do with a Scanner, where you can just set the delimiter: Scanner scan = new Scanner(new File("/path/to/file.txt")); scan.useDelimiter(Pattern.compile(";")); while (scan.hasNext()) { String logicalLine = scan.next(); // rest of your logic } ...

Python - Select specific value from test file

python,file,text

You could split the text and have a list of lists, where each sub list is a row, then pluck whatever you need from the list using rows[row - 1][column - 1]. f = open('test.txt', 'r') lines = f.readlines() f.close() rows = [] for line in lines: rows.append(line.split(' ')) print...

javscript readstream line by line

javascript,file,csv,io

Should be easier if you go easier ... var fs = require('fs'), readline = require('readline'); var rd = readline.createInterface({ input: fs.createReadStream('Domain.csv'), output: process.stdout, terminal: false }); rd.on('line', function(line) { console.log(line); }); ...

Strings vs binary for storing variables inside the file format

c++,file,hdf5,dataformat

Speaking as someone who's had to do exactly what you're talking about a number of time, rr got it basically right, but I would change the emphasis a little. For file versioning, text is basically the winner. Since you're using an hdf5 library, I assume both serializing and parsing are...

File is not being downloaded when requested through Ajax using JQuery

javascript,jquery,ajax,file,csv

I would recommend you create the CSV at server side PHP program and set Content-Type as "application/vnd.ms-excel" (or) "text/csv" and set "Content-Disposition: attachment; [yourfilename] " Refer this Create a CSV File for a user in PHP Refer this Force Download CSV File Simply put hyperlink as <a class="areaSummaryExport" href="admin_ajax.php" value="1">...</a>...

Redirect output to 'file' command

file,ar

Use file -. The hyphen means "take input from standard input".

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

file,actionscript-3,air,lan

While I don't know of a method to make File.exists() perform faster (likely there is no way as it's more of an OS issue), you can at least mitigate the issue by using asynchronous operations instead - thus avoiding locking the UI. You can skip the exists operation, and just...

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

Here's my guess: Since you're discarding all new-line characters, you end up with a single enormously long line, which your console is having troubles handling. (I've experienced this myself in the Eclipse console.) Try changing fileContent.append(line); to fileContent.append(line).append('\n'); As @assylias points out you also might want to drop Vector (and...

Read and Write the specific content

python,file

You first need to detect whether you are inside a "Bar" block. Then, while you are, print/accumulate those lines that start with * [x]. Here's one way to do it: def get_selected_block_entries(lines, block_name, block_prefix='#####', selected_entry_prefix='* [x]'): selected_lines = [] block_marker = '{} {}'.format(block_prefix, block_name) for line in lines: if line.startswith(block_prefix):...

how to save information from a file in java

java,string,file,io

To read files I recommend to you to use an ArrayList: Scanner s = new Scanner(new File(//Here the path of your file)); ArrayList<String> list = new ArrayList<String>(); while (s.hasNext()) { list.add(s.nextLine()); } Now in your ArrayList you will have all the lines of your file. So, now, you can go...

C++ reading and editing files

c++,file

This is the start of what you want. Because this is an assignment I have left you with some reading, and the remainder of the assignment. I have also translated much of the code to read in Portuguese. #include <iostream> #include <fstream> // seu códe // Faça isso para ler...

Appending lines for existing file in python [duplicate]

python,file,python-2.7,io

The issue is in the code - curr_file = open('myfile',w) curr_file.write('hello world') curr_file.close() The second argument should be a string, which indicates the mode in which the file should be openned, you should use a which indicates append . curr_file = open('myfile','a') curr_file.write('hello world') curr_file.close() w mode indicates write ,...

Append a line to file when blank line appears

java,string,file

As soon you read an empty line you need to output your orange and melon line. And additional when you reach the end of the file. Find a snippet where you could start with. create an new file with the addtional llines String newLine; try (PrintStream output = new PrintStream("fruits.out");...

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

Here's a function that returns whether a filename matches your YY-MM-DD.csv pattern or not. from datetime import datetime def is_dated_csv(filename): """ Return True if filename matches format YY-MM-DD.csv, otherwise False. """ date_format = '%y-%m-%d.csv' try: datetime.strptime(filename, date_format) return True except ValueError: # filename did not match pattern pass return False...

Android contact image placeholder in listview

android,file,uri,contacts,android-contacts

The idea to check if the file exists led me to this post where it was answered detect if contact has photo .getDrawable() == null gets the correct result. thanks for all comments...

Read text file from specific position and store in two arrays

c#,arrays,file,text

All strings after @relation SMILEfeatures and contains @attribute are stored in first array. All the strings after @data should are stored in the second array. Hope this is what you wanted. var relationLineNumbers = new List<int>(); var dataLineNumbers = new List<int>(); var relation = new StringBuilder(); var data = new...

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

android,file,local-storage

Simplest options is always thebest option, go with shared preferences Here is simple tutorial from google http://developer.android.com/training/basics/data-storage/shared-preferences.html It will store your data in application local file. Take a note of that there are different shared preferences in example getPreferences() will return file specific for activity you used this method. While...

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

php,image,file,properties,file-attributes

I don't believe that PHP natively contains a function to edit the EXIF data in a JPEG file, however there is a PEAR extension that can read and write EXIF data. pear channel-discover pearhub.org pear install pearhub/PEL Website for the module is at http://lsolesen.github.io/pel/ and an example for setting the...

Why is my linked list only printing last entry?

c,file,linked-list

The problem is the way you are treating the result of strtok: you are setting its value right into the node, instead of copying it. Make a copy of name when adding a node: void push(node ** head, int uid ,char* uname) { node * new_node; new_node = malloc(sizeof(node)); new_node->uid...

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

java,file,constructor,static-analysis,hardcoded

As a general rule of thumb, hardcoding absolute paths makes your program less flexible. Consider a configuration file located at /usr/share/myapp/myapp.conf - what if the end user wants to install your application somewhere else than /usr/share? Using such an absolute path will break the application. And as always, no general...

While appending to file if condition always fails

java,string,file

EDIT: After explaining your logic, it looks like you need to keep track of which of the 4 special Strings appeared in the current record, and to add whichever of them didn't when the record ends. You can do it with 4 boolean variables. boolean osi = false; boolean posi...

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

python,image,list,file,python-imaging-library

Quick fix First, you need to have your pixel tuples in a single un-nested list: pixels_out = [] for row in pixels: for tup in row: pixels_out.append(tup) Next, make a new image object, using properties of the input image, and put the data into it: image_out = Image.new(image.mode,image.size) image_out.putdata(pixels_out) Finally,...

How does one rename multiple files within folders using python?

python,file,python-3.x,rename,file-rename

You don't need all the lists, just rename all files on the fly. import sys, os, glob newnames = ["North", "South", "East", "West"] for folder_name in glob.glob(sys.argv[1]): for new_name, old_name in zip(newnames, sorted(os.listdir(folder_name))): os.rename(os.path.join(folder_name, old_name), os.path.join(folder_name, new_name)) ...

Assign hash to array

arrays,ruby,file,hash

You could do: size = Hash[arr.zip(arr_s)] To give you a better idea, in irb, I typed: a = (1..5).to_a => [1, 2, 3, 4, 5] b = ('a'..'e').to_a => ["a", "b", "c", "d", "e"] Then, typing size=Hash[a.zip(b)] Returns {1=>"a", 2=>"b", 3=>"c", 4=>"d", 5=>"e"} So you could do: puts size[1] which...

How would I read a text file in C?

c,file,fread

I usually use the fgets() function to a file on a line-per-line basis (provided it is a text file). #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define LINELEN 200 #define NAMELEN 40 struct PRICELIST { char item[NAMELEN]; float price; unsigned int order_no; struct PRICELIST *next; struct PRICELIST *prev; };...

ERROR: variable “string” is not initialized

c,arrays,string,file

That's normal, you didn't allocate string. C needs you to allocate it in memory before you use it. Also you will have to know its size. In your code, string points to nowhere into memory so it doesn't exist (to be exact it points to somewhere you have a lot...

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

c,file

You can read the input from user and append .txt char fileName[30]; // ... scanf("%25s", fileName); // max 25 characters because .txt have 4 (25+4 = 29) strcat(fileName, ".txt"); // append .txt extension // ... FILE *f = fopen(fileName, "a"); ...

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

file,png,formats

Extract from http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-signature The first two bytes distinguish PNG files on systems that expect the first two bytes to identify the file type uniquely. The first byte is chosen as a non-ASCII value to reduce the probability that a text file may be misrecognized as a PNG file; also, it...

What is wrong with the function strtok()?

c,arrays,string,file,dynamic-memory-allocation

The problem with strtok is that the token it returns you becomes invalid as soon as you make the next call of strtok. You could either copy it into a separate string, or use it right away, and discard, but you must use it before calling strtok again. for (i...

File not Uploading using Ajax in cakephp

php,jquery,ajax,file,cakephp

With this AJAX form submission approach, you will not be able to upload file using ajax. If you don't like using a third-party plugin like dropzone.js or Jquery file upload, you can use XMLHttpRequest. An example below: $('#newcatform').on('submit', function(ev){ ev.preventDefault(); var forms = document.querySelector('form#newcatform'); var request = new XMLHttpRequest(); var...

Changing file name to the user's name PHP

php,file,upload

You need to change your $target_file variable to the name you want, since this is what gets passed into move_uploaded_file(). I don't see anywhere in your code where you actually set this variable to their username (right now it's still using the name they selected when they uploaded it). Without...

Rust: Lifetime of String from file [duplicate]

file,io,rust

The string bound to "s" will be deallocated once the function ends ("s" goes out of scope), so you cannot return a reference to its contents outside the function. The best way is to return the string itself: fn read_shader_code(string_path: &str) -> String { let path = Path::new(string_path); let display...

Getting HTTP 302 when downloading file in Java using Apache Commons

java,file,url,apache-commons,fileutils

The code 302 refers to a relocation. The correct url will be transmitted in the location header. Your browser then fetches the file form there. See https://en.wikipedia.org/wiki/HTTP_302 Try https://repo1.maven.org/maven2/com/cedarsoftware/json-io/4.0.0/json-io-4.0.0.jar For FileUtils see How to use FileUtils IO correctly?...

FileNotFoundException EACCES (Permission Denied)

android,file,exception,filenotfoundexception

Android is case sensitive. Replace ANDROID.PERMISSION with android.permission: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> Also, you should only need one of those permissions. If you are planning on writing to external storage, you should not also need READ_EXTERNAL_STORAGE....

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

c,arrays,file,fscanf

OP's code problems include: 1) Passing a variable, rather than an address of a variable in fscanf(read_from, " ch=1 n=%d v=%d", array[u][2], array[u][3]); 2) Insufficient space reading "Off" with char status[3]; ... ctrl = fscanf(read_from, " %s", &status); The better approach is to not use fscanf(). Read the line using...

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

php,file,mysqli,upload

I see you have called the bindParameters() method after calling execute(). It should be the other way round. i.e. $stmt->bind_param('ssis',$complete,$file_name,$fileSize,$myUrl); $stmt->execute(); ......

KeyError while executing Python Code

python,file,csv

Probably your csv don't have a header, where the specification of the key is done, since you didn't define the key names. The DictReader requires the parameter fieldnames so it can map accordingly it as keys (header) to values. So you should do something like to read your csv file:...

Searching for a sentence in a file java [closed]

java,file,search

You can always use the String#contains() method to search for substrings. Here, we will read each line in the file one by one, and check for a string match. If a match is found, we will stop reading the file and print Match is found! package com.adi.search.string; import java.io.*; import...

How to get rid of .ignore file in Git?

git,file,bitbucket,ignore

.gitignore is just like any other file under version control, so yes, you can delete it. However, keep in mind that it probably has entries in it that should be kept, so instead of deleting it, I would just modify it so that your jar files are no longer ignored.

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

c#,string,file,text

If you know the extensions that can show up you can use the following solution with a regex: //regex for file name with known extensions Regex r = new Regex("^.*\\.(ext|doc|PUT_OTHER_EXTENSIONS_HERE)$"); var lines = File.ReadAllLines(FILE_PATH); var res = lines.Where(x => !string.IsNullOrWhiteSpace(x) && r.Match(GetFirstEntry(x)).Success) .Select(x => GetFirstEntry(x)); where GetFirstEntry : /// <summary>...

C - Reading from a file

c,file,fgetc

/*Everything looks find in your code. in my machine it is working fine . I have only added a if condition to print the contents same as the file thats it .. */ #include<stdio.h> int main(void) { FILE *fp; int c; fp = fopen("rabi.txt","r"); if(fp == NULL) { perror("Error in...

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

arrays,string,algorithm,file,data-structures

For instance a single string matching is the z-algorithm. It's the fastest matcher.

IllegalStateException: Iterator already obtained [duplicate]

java,file,loops,path

You have to call DirectoryStream<Path> files = Files.newDirectoryStream(dir); each time you iterate over the files. Pls check this question... java.lang.IllegalStateException: Iterator already obtained...

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

vb.net,file,file-access

I don't know if you can write to a specific line in a file, but if you need to you can write your lines to a List then write the list to a file 'Declare your list Dim lines As New List(Of String) For Each lineToWrite In YourLines If toInsert...

Python - Deleting the first 2 lines of a string

python,string,file,parsing,lines

I don't know what your end character is, but what about something like postString = inputString.split("\n",2)[2]; The end character might need to be escaped, but that is what I would start with....

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

python,string,file,integer,logic

By conversion to string, you hide the error. Always try repr(value) instead of str(value) for debugging purposes. You should also know, that it is better to compare integers instead of strings -- e.g. " 1" != "1". Edit: From your output, it is clear that you have an extra '\n'...

Add up numbers in files

java,file,add

This is exactly what you need. It will check all files dynamically, you don't need to give number of files. for example, if you have any number of files and various number of rows in each file, not to worry. it will read it correctly. import java.io.*; import java.util.*; import...

How to convert a file name when using Java Mail API

java,file,email

Filename isn't a base64 encoded string. It is encoded as defined by RFC 2047. Don't try to decode such strings by hand. Use solid libraries like Apache Mime4j for encoding/decoding mime messages. Add Mime4j to your project (here Maven): <dependency> <groupId>org.apache.james</groupId> <artifactId>apache-mime4j-core</artifactId> <version>0.7.2</version> </dependency> Use org.apache.james.mime4j.codec.DecoderUtil for decoding quoted-printable strings:...

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

php,file,explode

1. Since you use fgets(), yes this is the expected behaviour, since you grab the full line, which includes the new line character at the end. 2. You can just use fgetcsv() and specify the delimiter as tab, e.g. $handle = fopen("test.csv", "r"); if ($handle) { while (($data = fgetcsv($handle,...

Realm.io Removing the realm file

ios,file,realm

That is the proper way of deleting it. You can check the Migration example in the RealmExample project that come with the SDK and see that that's exactly how they do it, so I assume the recommended way. let defaultPath = Realm.defaultPath NSFileManager.defaultManager().removeItemAtPath(defaultPath, error: nil) ...

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

c,file

Since the next thing we plan to do is create something at that location, and since we want to treat it as an error if something already exists there, then let's not bother checking. Just attempt the create and exit with an error if it fails. The create step uses...

fast conversion of a text file to arrays C++

c++,arrays,string,file,large-data

part 2 If you are reading the file back onto the same type of system (endianness) then use a binary blittable format. Ie store a straight binary dump of the 200 * 200 array. I would also multiply by 1000 and store as ints since they are typically slightly faster...

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

php,file,header,flat

I would like to have a loop read first header store in variable then read details and everytime it hits 'I' it uploads that line to MYSQL. There are multiple ways to parse your file. The following approach makes use of explode() for H and I. So you have...

Scala: load different files by input

file,scala,input

I tried to make this a bit more generic. To show how this can be helpful, I also created another command that you can call as "add 1 2" and it will print the sum of adding the two integers. If you are serious into making a CLI interactive application,...

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

file,strace

It's the spurious terminating ; in line2 - remove it! Your loop will run until 10 while doing nothing (the final semicolon means an empty statement), and then the command in braces executed once.

How to remove numbers from extensions from files

file,shell,rename

A pretty portable way of doing it would be this: for i in *.text*; do mv "$i" "$(echo "$i" | sed 's/([0-9]\{1,\})$//')"; done Loop through all files which end in .text followed by anything. Use sed to remove any parentheses containing one or more digits from the end of each...

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

file,vim

You can use: gf to edit the file name under the cursor in the current window (requires 'nomodified' on the existing buffer in the current window). ^wf to edit the file name under the cursor in a new window. (Note: conveniently, ^w^f also works.) ^wgf to edit the file name...

HTML read local file not selected by user

javascript,html,file

No. Websites cannot access arbitrary files on the computer the browser is running on. That would be a terrible security risk. It sounds like you would be better off cutting the browser out entirely. Possibly using Node.js or WSH if you want to use JavaScript to perform your updates....

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

vba,file,csv

You're not actually opening the file in Excel so you can't count how many cells there are. Try reading how many lines instead: Open FilePath & file For Input As #1 While Not EOF(1): Line Input #1, trashLine: Wend i = i + 1 Close #1 Alternatively, open the file...

Insert string at line number nodejs

javascript,node.js,file

As long as the text file isn't that large, you should be able to just read in the text file into an array, insert an element into the specific line index, and then output the array back to the file. I've put some sample code below - make sure you...

Downloading file from Java servlet gives null

java,file,servlets,stream

This solution is a modified solution from BalusC File Servlet blog. The reason I use this solution is because it reset() the HttpServletResponse response before writing data. @WebServlet(urlPatterns = { "/Routing/*" }) @MultipartConfig(location = "/tmp", fileSizeThreshold = 1024 * 1024, maxFileSize = 1024 * 1024 * 5, maxRequestSize = 1024...

File security System in java? [on hold]

java,file,security,encryption

So to encrypt an aspect of the file you may want to gather it's bytes in an array*, That can either be done using the class Files from java or a stream to do it manually. For now lets say you got the byte array obtained using Files.readAllBytes(Path file); So...

Reading an external txt file on main.class

java,file,stream,external

The path you have mentioned in the FileReader is wrong... If file is in the same folder in which your java program is present then the path would be.... And also tell me y are you using the input stream its not necessary... BufferedReader br = new BufferedReader(new FileReader("LerDaqui.txt"));

JOptionPane Message with File Path

java,swing,file,path,joptionpane

JOptionPane.showMessageDialog(null,"your file path,remember to use double slahses instead of single ones"); ...

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

java,string,file,replace

First of all, the code you wrote here is not working, because when you open an outputStream to the exact file you try read from, it will empty the source file and the statement in.readLine() always returns null. So if this is your real code maybe this is the problem....

Reading a text file with Tabs

c#,asp.net,.net,file,readfile

There's no tab entity defined in ISO-8859-1 HTML, so I think you can replace tab characters with some &nbsp; characters: if (File.Exists(path)) { using (TextReader tr = new StreamReader(path)) { while (tr.Peek() != -1) { var htmlLine = tr.ReadLine().Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;") + "<br/>"; Response.Write(htmlLine); } } } ...

Group instances based on NA values in r

r,file,csv,instance,na

df[!is.na(df$Value), ] Size Value Location Num1 Num2 Rent 1 800 900 <NA> 2 2 y 3 1100 1300 uptown 3 3 n 4 1200 1100 <NA> 2 1 y And df[is.na(df$Value), ] Size Value Location Num1 Num2 Rent 2 850 NA midcity NA 3 y 5 1000 NA Lakeview NA...

Java BufferedReader - empty line issue

java,file,javafx,line,bufferedreader

As it turned out in the discussion, the problem is that with readLine() the following files will behave the same way: File A: "Hello\n" File B: "Hello" 1st readLine() --> "Hello" 2nd readLine() --> null ==> we cannot know if there was a '\n' after the last line or not...

Check docx is corrupted or not

c#,file,openxml

Take a look in this page: How to: Validate a word processing document. Using the Open XML SDK, you can write a code like this: public static void ValidateWordDocument(string filepath) { using (var wordprocessingDocument = WordprocessingDocument.Open(filepath, true)) { try { OpenXmlValidator validator = new OpenXmlValidator(); int count = 0; foreach...

Java dir/files list

java,file,dir

Removed error from your version In your recursion you never ask for null values. Do it and it should run like this: public static List<File> listf(String directoryName) throws IOException { File directory = new File(directoryName); List<File> resultList = new ArrayList<>(); // get all the files from a directory File[] fList...

FileReader: reading many files with javascript without memory leaks

javascript,file

The problem may be related with the order of execution. In your for loop you are reading all files with reader.readAsArrayBuffer(file). This code will run before any onload is run for a reader. Depending on the browser implementation of FileReader this can mean the browser loads the entire file (or...

introduce c++ into html

html,c++,file,class

First you're using non-ascii characters in your pathname. I've never tried to do it so I can't help you there but maybe you can try the answer here Open File with Non ASCII Characters You're doing it wrong, the way you go about writing to the file. I assume that...

Storing columns on disk and reading rows

c++,file,matrix,io

Mentioned solution with fseek is good. However, it can be very slow for large matrices (as disks don't like random access, especially very far away). To speed up things, you should use blocking. I'll show a basic concept, and can explain it further if you need. First, you split your...

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

c#,.net,file,thread-safety

When a process opean a file for Read/Write with FileShare.None any subsequent access by any process on this same file will result in Acess Denied Exception. To answer your question, Second user will get exception. MSDN: FileShare.None - Declines sharing of the current file. Any request to open the file...

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

node.js,file

Because you will have to read the line to know where is ending and also you have to write at the end of the each line. In conclusion you have to read everything and write at the end of each line just appending won't save to much performance it only...

Mark a file as created by my app

c#,.net,file,pdf

There are actually 3 ways: Write a signature and properties into PDF file and then read back. This requires to use specialized 3rd party PDF library to write, read, add signature to PDF; Maintain a separate XML file with detailed information like last updated, version, CRC or MD5 value to...

File association using CMD

file,cmd,associations

One needs to use ftype and assoc commands as follows (and note that sequence matters): ftype txtfile="C:\Program Files (x86)\PSPad editor\PSPad.exe" "%1" assoc .log=txtfile assoc .txt=txtfile assoc .wtx=txtfile or ftype TIFImage.Document="C:\Program Files\MSPVIEW.exe" "%1" assoc .tif=TIFImage.Document assoc .tiff=TIFImage.Document Note that I haven't MSPVIEW.exe installed so I can't approve your ftype assignment rightness....

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

file,delphi,variables,assign

Is it possible to use a variable in the AssignFile command? Yes. The second parameter of AssignFile has type string. The expression cFileDir + '\' + sFile has type string. FWIW, AssignFile is known as a function rather than a command. Getting on top of terminology like this will...

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

python,file,dictionary

dict() does not parse Python dictionary literal syntax; it won't take a string and interpret its contents. It can only take another dictionary or a sequence of key-value pairs, your line doesn't match those criteria. You'll need to use the ast.literal_eval() function instead here: from ast import literal_eval if line.startswith(self.kind):...

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

c#,file

You can use Path to separate FileName into a file name and an extension, insert the date in the middle, and combine them back, like this: var fn = Path.GetFileNameWithoutExtension(FileUpload1.FileName); var ext = Path.GetExtension(FileUpload1.FileName); var fileName = string.Format("{0}{1:yyyy-MM-dd}.{2}", fn, DateTime.Now, ext); ...

Python3 create files from dictionary

file,python-3.x,dictionary

Remove the if not len(key) != len(aDict) and the break. What you probably wanted to do is stopping the loop after iterating all the keys. However key is one of 'OG_1', 'OG_2', 'OG_XX', it's not a counter or something like that. Replace open("key", "w") with open(key + ".txt", "w")....

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

c,linux,file,echo,system

There is one new line, which is to be expected. The echo command prints all its arguments on a single line separated by spaces, which is the output you see. You need to execute the result of: echo "$(ls %s)" to preserve the newlines in the ls output. See Capturing...

Check if file exists using Apache Commons VFS2

java,file,sftp,apache-commons-vfs

Use FileObject.exists() method. See https://commons.apache.org/proper/commons-vfs/apidocs/org/apache/commons/vfs2/FileObject.html#exists%28%29...

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

java,file

String line; PrintStream out = null; BufferedReader br = null; try { out = new PrintStream(new FileOutputStream(outputFile)); br = new BufferedReader(new FileReader(inputFile)); while((line=br.readLine())!=null){ if(line.trim().isEmpty()) { out.println("proc_online_system_id"); //print what you want here, BEFORE printing the current line } out.println(line); //always print the current line } } catch (IOException e) { System.err.println(e);...

Encrypting (large) files in PHP with openSSL

php,file,encryption,aes,php-openssl

You could use CBC encryption using Mcrypt and then encrypt a segment of data at a time. Make sure that the segment is x times the block size of the used cipher (e.g. 16 bytes for AES). Encrypt the segment and take the last block of the generated ciphertext and...

Python3 string and hmac auth

string,file,python-3.x

read() will read the entire file. Try with readline(). with open('keys', 'r') as f: key = f.readline().rstrip() secret = f.readline().rstrip() print(key) print(secret) # ewjewej2j020e2 # dw8d8d8ddh8h8hfehf0fh or splitting read: with open('keys', 'r') as f: key, secret = f.read().split() print(key) print(secret) # ewjewej2j020e2 # dw8d8d8ddh8h8hfehf0fh with open('keys', 'r') as f: key,...

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

file,fonts,true-type-fonts,legal,fees

You did not do your homework in looking up how fonts actually work before asking your question. Next time, please do. Now, while there exists a "ttf format", it has nothing to do with the font format itself, instead only specifying how to encode glyph outlines in a binary block...