Skip to main content
Share Your Experience: Take the 2024 Developer Survey
17 votes
Accepted

O PC, why are you so slow?

...
Mast's user avatar
  • 13.4k
15 votes
Accepted

#TODO Remove duplication in XML parsing

Low hanging fruit Most of this will come down to reading PEP8, however I'll state them here anyway. From the top down: If statements don't need brackets, so don't put them around them. Functions at ...
Peilonrayz's user avatar
  • 43.4k
13 votes

xml is XML is xml is XML

Naming There are .NET Naming Guidelines which state that methods should be named using PascalCase casing. You haven't done this for ...
Heslacher's user avatar
  • 50.4k
9 votes
Accepted

SQL query to compare two XML columns

Try this query instead on your data and tell how it performs. Not sure it will return exactly the same as your query but it should be close enough so you can adjust to what you want. ...
Mikael Eriksson's user avatar
9 votes
Accepted

Convert XML to CSV

First of all, I'd split the convert method out into it's own thing - separate from the loading and saving: ...
Pj-'s user avatar
  • 106
8 votes
Accepted

Return XML file from Web API

Dependency Inversion Priciple The smell is that your code violates the Dependency Inversion Priciple which reads Entities must depend on abstractions not on concretions. It states that the high ...
t3chb0t's user avatar
  • 44.3k
8 votes
Accepted

xml is XML is xml is XML

One should also add that: Both the ReturnNameAsString and the buildString methods could be ...
t3chb0t's user avatar
  • 44.3k
7 votes

O PC, why are you so slow?

It's going to be hard to improve this very much, because your code is likely limited by the network IO you're doping to connect to OPC. On my machine I've disabled the OPC calls (I don't have it ...
Dan Oberlam's user avatar
  • 7,804
7 votes

Determine if a file is either in JSON or XML format

Well, if you only need to distinguish between JSON and XML formats I'd keep it simple. If the encoding of that string is known ...
Grajdeanu Alex's user avatar
7 votes

Locating people by roleId

You can introduce range variables to hold data which you need several times in your query: ...
Sergey Berezovskiy's user avatar
7 votes
Accepted

Getting information about music that is popular in a country

Imports First, let me suggest you look at the PEP 8 style guide. I don't follow all of the suggestions myself, but some of them make good sense, including the suggestions on the arrangement and ...
aghast's user avatar
  • 12.4k
7 votes

XML design for parsing in C#

You are trying to recreate functionality that is already provided out of the box. Reference Configure an ASP.NET Core App From documentation it supports providers for INI, JSON, and XML. Each ...
Nkosi's user avatar
  • 3,246
6 votes

Converting XML to DOT

There's an XML syntax for DOT called DotML at http://martin-loetzsch.de/DOTML/. Generating a generic DotML tree from XML is very straightforward using XSLT. Most of it is just: ...
Michael Kay's user avatar
6 votes

Classes for reading XML from a file

It's a small code snippet but IMO you may improve few things about style: Usually (in .NET environment) properties are TitleCase as well as classes. Whatever your favorite naming convention is you ...
Adriano Repetti's user avatar
6 votes

Program to search many files and remove a certain string

I cannot look at it. You treat a XML like it was a normal text file. This is insane. You should parse it with the XDocument.Load, find all the ...
t3chb0t's user avatar
  • 44.3k
6 votes

Parsing XML commands and parameters

Multiple things to fix: variable naming - class names should be in camel-case and start with a capital letter (reference); when there are multiple words in a variable, you should put underscore ...
alecxe's user avatar
  • 17.3k
5 votes
Accepted

Xml serialize to object

Some quick remarks: You don't need regions in a 50 line class. In fact, avoid regions. Why do you store procedureDataManager and ...
BCdotWEB's user avatar
  • 11.2k
5 votes

Xml serialize to object

I would suggest not to recreate the instance of XmlSerializer each time, because it creates an assembly in memory that is not reused / unloaded. To avoid that, just ...
JanDotNet's user avatar
  • 8,538
5 votes

SQL query to compare two XML columns

Nitpicks Here are a few small critiques to start with: Single-letter table reference aliases are often discouraged because they do not convey any meaning, such that you have to go back to their ...
Phrancis's user avatar
  • 20.4k
5 votes
Accepted

Turn XML into Object

It is a good Idea to create a generic object model that may represent an XML document. Therefore, the .Net Framework already contains such models: XmlDocument and XDocument. I would really suggest to ...
JanDotNet's user avatar
  • 8,538
5 votes
Accepted

Using QXmlStreamReader to read configuration file of key-value pairs

Case for not using a class It's not clear to me whether you need a class for what you are doing. Unless you need to be able to construct an instance of ...
R Sahu's user avatar
  • 3,502
5 votes

Deserialize, Copy and Merge Orders from XML to C#

Naming var orders = new List<XElement>(); var _orders = new List<Order>(); First, according to the C# naming convention, you should never have ...
IEatBagels's user avatar
  • 12.4k
5 votes
Accepted

Python CSV to XML converter

The real issue with repeating yourself here is that you are iterating over your dataframe twice when you don't have to. Fortunately, the devs for lxml make the ...
C.Nivs's user avatar
  • 2,947
5 votes

Reading Data from XML and storing them into SQL Database

Review Single responsibility principle Method save_vendor_info (which we'll rename later) does data retrieval from an external source, xml to db mapping, and SQL ...
dfhwze's user avatar
  • 13.9k
5 votes

Reading Data from XML and storing them into SQL Database

As dfhwze says, you should probably pull in the connection string/information from an external source: the production database hopefully won't be called 'TEST', which means you can't use this code in ...
VisualMelon's user avatar
  • 7,431
5 votes
Accepted

Performance - Read large amount of XMLs and load into single csv

TLDR: it can be done much more quickly and much more concisely, in 28 minutes end-to-end, and in 12 minutes when all XML are already on disk. The key trick: using the long rather than wide format for ...
TemplateRex's user avatar
  • 1,938
5 votes
Accepted

XML attribute analysis

Regarding the primary question, your code is very close to being a well-defined function. Simply wrap the entire code in a function, making filename the right ...
Salim's user avatar
  • 66
5 votes

Format potentially invalid XML

There's a test suite of 2000 test cases available at https://www.w3.org/XML/Test/ - try it out. From a quick glance, it's not clear to me how you're handling content within comments or CDATA sections -...
Michael Kay's user avatar
5 votes
Accepted

Translate SOAP response into a CSV using Python

It makes little sense to slice the data into "vertical" lists, then transpose them back into rows using zip(). Not only is it cumbersome to do it that ...
200_success's user avatar
4 votes

Serializing a list

Your class has a private constructor then it can't be derived, make it explicit using sealed: ...
Adriano Repetti's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible