parsing

Java.lang.NumberFormatException error: empty string- Exchange Rate application

∥☆過路亽.° 提交于 2021-02-17 06:55:12
问题 I'm writing a program which gets daily exchange rates from http://www.tcmb.gov.tr/kurlar/today.xml and saves them to the List. Here is my code: public class ParseTheXml { private List<CurrencyPojo> currencyList; public void setCurrencyList(List<CurrencyPojo> currencyList) { this.currencyList = currencyList; } public List<CurrencyPojo> getCurrencyList() throws ParserConfigurationException { currencyList = new ArrayList<CurrencyPojo>(); try { DocumentBuilder builder = DocumentBuilderFactory

How to remove multiple lines from a file with python

家住魔仙堡 提交于 2021-02-17 06:39:08
问题 I'm trying to remove lines from a file using this code: with open('example_file', 'r') as file: file_content = file.readlines() file.close() with open('example_file', 'w') as new_file: for line in file_content: if line.strip("\n") != 'example_line_1': new_file.write(line) new_file.close() This works well for one line but how can I remove other (multiple) lines as well? 回答1: You could do it using and . ... with open('example_file', 'w') as new_file: for line in file_content: currentLine = line

Parsing UnregisterHotkey from usercontrol to parent form

家住魔仙堡 提交于 2021-02-17 06:33:31
问题 So I'm attempting to get the userinputs when someone presses hotkeys, also outside the form (in this case SHIFT+A). Now since I wanted to add tabs to my forms application I decided to go with usercontrols, now the problem is, that I am unable to access the formclosing event (from form1) on the usercontrol, meaning I would have to somehow parse whatever I wanted to execute in the formclosing event. Usercontrol (named home) public partial class Home : UserControl { [System.Runtime

Parsing UnregisterHotkey from usercontrol to parent form

こ雲淡風輕ζ 提交于 2021-02-17 06:33:20
问题 So I'm attempting to get the userinputs when someone presses hotkeys, also outside the form (in this case SHIFT+A). Now since I wanted to add tabs to my forms application I decided to go with usercontrols, now the problem is, that I am unable to access the formclosing event (from form1) on the usercontrol, meaning I would have to somehow parse whatever I wanted to execute in the formclosing event. Usercontrol (named home) public partial class Home : UserControl { [System.Runtime

How does one parse best each item of an ingredient list and does create a new object based on each parsing result?

耗尽温柔 提交于 2021-02-17 06:05:21
问题 I have this list of ingredients I am trying to make a regex to look for 1 cup , or 1 tsp or 1 tablespoon and so on..... I have made this regex but It doesn't work as well. I am trying separate ingredients from the measurements. So with this string 1 Chopped Tomato it should take out the 1 as amount and output this: const output = [ { val: "Chopped Tomato", amount: "1", }, And with this string below it should be able to take out ½ tsp from ½ tsp fine salt and output this: const output = [ {

How to have an XML tag start with a number?

假装没事ソ 提交于 2021-02-16 19:13:31
问题 I'm using ElementTree API to read and write to an XML document. When I try to add a tag that starts with a number, the XML file is no longer valid. Using import xml.etree.cElementTree as ET , I am successfully able to create the XML document, but when I try to read in the XML file again, I get a ParseError. For my purposes, it does not matter if the XML document is not well formed. I just need to be able to start a tag with a number. Any idea how to do this? This is what I have tried: from

Does Eclipse CDT's parser/indexer have a “self-identifying” preprocessor #define macro?

别等时光非礼了梦想. 提交于 2021-02-16 16:55:30
问题 I want to have some code only be included when Eclipse is parsing my source tree. At the moment, what I am doing^H^H^H^H^H trying to do is add a custom preprocessor macro - using Eclipse's Help | Preferences | C/C++ | Build | Setting Discovery - and insert a -DECLIPSE_BUILTIN into the various command-lines there. So I was wondering whether there is already a standard, a default, macro which the preprocessor (and the indexer?) define to 'identify' themselves like this to the code - to save me

java.time DateTimeFormatter pattern for timezone offset

余生长醉 提交于 2021-02-16 04:19:49
问题 I am trying to parse: 2014-05-02-10.45.05.993280-5:00 where the -5:00 is the offset from UTC. Using a java.time DateTimeFormatter in Java 8. For the first bit I have the following: yyyy-MM-dd-HH.mm.ss.SSSSSS however, I can't figure out what the pattern should be to parse the offset also. If I had the offset with 4 digits (-05:00) I could use: yyyy-MM-dd-HH.mm.ss.SSSSSSxxx , but this doesn't work for 3 digits. Any ideas? 回答1: Use capital letter X instead of x, hence XXX. The difference is that

Add Column to end of CSV file using 'awk' in BASH script

我们两清 提交于 2021-02-15 10:49:15
问题 How do you add a column to the end of a CSV file with using a string in a variable? input.csv 2012-02-29,01:00:00,Manhattan,New York,234 2012-02-29,01:00:00,Manhattan,New York,843 2012-02-29,01:00:00,Manhattan,New York,472 2012-02-29,01:00:00,Manhattan,New York,516 output.csv 2012-02-29,01:00:00,Manhattan,New York,234,2012-02-29 16:13:00 2012-02-29,01:00:00,Manhattan,New York,843,2012-02-29 16:13:00 2012-02-29,01:00:00,Manhattan,New York,472,2012-02-29 16:13:00 2012-02-29,01:00:00,Manhattan

Writing an HTML Parser

拥有回忆 提交于 2021-02-15 10:24:39
问题 I am currently attempting (or planning to attempt) to write a simple (as possible) program to parse an html document into a tree. After googling I have found many answers saying "don't do it it's been done" (or words to that effect); and references to examples of HTML parsers; and also a rather emphatic article on why one shouldn't use Regular expresions. However I haven't found any guides on the "right" way to write a parser. (This, by the way, is something I'm attempting more as a learning