Posts

arrays - Python (scipy) import time from text file -

i have text file: 2010-05-16 2010-09-26 2011-04-28 each line string: yyyy-mm-dd my goal read text file , write information array. import scipy sp x=sp.empty(200,ftype=sp.datetime64) file=open(place,'r') p in file: x[i]=p but not work. see "an error". how can solve task? know can use panda need write scipy array. try this: import numpy np x = np.empty(200, dtype='datetime64[d]') open(place, 'r') f: i, date in enumerate(f): x[i] = date.strip() firstly, it's dtype , not ftype . then, need use datetime64[d] since date, not date , time. then, date has newline @ end, results in parse error ( strip() fixes this). might want use np.zeros() instead of np.empty() . you can access these methods through scipy well, they're technically part of numpy, use import numpy np .

asp.net - Object reference not set to an instance of an object -

this question has answer here: what nullreferenceexception, , how fix it? 32 answers i new asp.net mvc , cannot find solution how make selectable dropdown list. my model: public class parentcategory { public int id { get; set; } [required] [display(name = "parent category name")] public string pcatname { get; set; } [required] [display(name = "urlseo")] public string urlseo { get; set; } [required] [display(name = "description")] public string pcatlogo { get; set; } public icollection<childcategory> childcategories { get; set; } } public class addparentcategoryviewmodel { public int id { get; set; } public string pcatname { get; set; } public string urlseo { get; set; } public string pcatlogo { get; set; } } my controller [htt...

javascript - pdf2json gives me a blank output txt file? -

i following "code example" guide on github. https://github.com/modesty/pdf2json#code-example in example says "parse pdf write .txt file (which contains textual content of pdf)", copied , pasted exact implementation local javascript file , called output text file blank. 'use strict'; let fs = require('fs'); let pdfparser = require("pdf2json"); let pdfparser = new pdfparser(); pdfparser.on("pdfparser_dataerror", errdata => console.error(errdata.parsererror) ); pdfparser.on("pdfparser_dataready", pdfdata => { fs.writefile("./node_modules/pdf2json/test/f1040ez.content.txt", pdfparser.getrawtextcontent()); }); pdfparser.loadpdf("./node_modules/pdf2json/test/pdf/fd/form/f1040ez.pdf"); is doing wrong? or not work on part? there alternatives pdf text converters nodejs without additional binaries installed? the frontpage documentation bit wrong! in order make work set pdfparser...

java - I get error (1, 19) when tapping on multiple buttons that play sound -

it works few buttons, when tap 6 of them work. ones don't work give error (1, -19). media player state wrapper set up, if need use states of "mp"s, let me know. public class soundfile { public soundfile(final activity activity, final string soundfile, int imgbuttonid, arraylist<mediaplayerstatewrapper> mps) { this.mp = new mediaplayerstatewrapper(); try { this.afd = activity.getassets().openfd(soundfile + ".mp3"); } catch (ioexception e) { e.printstacktrace(); } this.allmps = mps; mps.add(this.mp); this.position = (imagebutton) activity.findviewbyid(imgbuttonid); this.position.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { try { mp.reset(); mp.setdatasource(afd.getfiledescriptor(), afd.getstartoffset(), afd.getlength()); ...

replace words from string having more than 6 digits regex php -

i want replace words string having more 6 digits. example: 'my contact no (432)(323)(322). other number +1239343. 1 343as32240' to: 'my contact no [removed]. other number [removed]. 1 [removed]' i aware of regex , preg_replace. need correct regex this. you can use regex search: (?<=\h|^)(?:[^\h\d]*\d){6}\s* and replace [removed] . breakup: (?<=\h|^) # loookbehind assert previous position line start or whitespace (?: # start of non capturing group [^\h\d]*\d # 0 or more non-space , non-digits followed 1 digit ) # end of non capturing group {6} # match 6 of group \s* # followed 0 or more non-space characters code: $result = preg_replace('/(?<=\h|^)(?:[^\h\d]*\d){6}\s*/', '[removed]', $str); regex demo

asp.net - Dynamically create data table based on incoming Excel data in C#? -

i'm trying import excel sheet data table in c#. keep getting out of bounds exception because columns value being hard coded me. for (int c = 0; c <40; c++) { ... } so rather hard coding , having bunch of empty columns listed on data table, there way count columns being passed in before create table? thereby allowing me create table dynamically around incoming data? below code. if (fileupload.hasfile) { datatable dt = new datatable(); (int c = 0; c <40; c++) { dt.columns.add(c.tostring(), typeof(string)); } using (stream filestream = fileupload.postedfile.inputstream) using (streamreader sr = new streamreader(filestream)) { string = null; while ((a = sr.readline()) != null) { dt.rows.add(a.split(new char[] { ',' }).toarray()); } } gridview1.datasource = dt; gridview1.databind(); try using instead: datatable dt; ...

spring-boot-configuration-processor 1.3.3.RELEASE (or 1.3.0.RELEASE) gives compile error with Maven 3.0.4 -

i'm using spring-boot-configuration-processor 1.3.3.release maven 3.0.4 , maven-compiler-plugin:3.3 , gives compile error when using jdk 1.7. compile error gives no details either , in fact if have single interface class compile still fails. what odd if use jdk 1.8 or spring-boot-configuration-processor 1.2.6.release compilation works fine. here output of compilation. c:\git-repos\alpha>mvn -e -x clean compile apache maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500) maven home: c:\xxx\fc-maven java version: 1.7.0, vendor: oracle corporation java home: c:\temp\jdk1.7_64\jre default locale: en_us, platform encoding: cp1252 os name: "windows 7", version: "6.1", arch: "amd64", family: "windows" ... [debug] === reactor build plan ================================================ [debug] project: com.xxx.xyz:alpha:jar:5.0.0 [debug] tasks: [clean, compile] [debug] style: regular [debug] ============================================...