Shrinavat 16 Posted October 3 Hello everyone, I'm working on a utility that gathers PC configuration information and displays it in a TTree component. I want to be able to save this information to a file so that it can be compared with a similar file created at a later time. This would allow me to detect any changes in the PC's configuration, such as adding or removing hardware components. My main challenge is deciding on the best format to store this data for easy comparison and change detection. I've considered options like JSON, XML, and plain text, but I'm unsure which would be most suitable. A simple line-by-line comparison of a text file might not be reliable, as the order of components could change without signifying an actual configuration change (e.g., reordering hard drives). Could anyone offer advice on the best approach for storing and comparing this type of data? Are there any specific technologies or libraries that would be helpful for this task? Any guidance would be greatly appreciated! Share this post Link to post
FPiette 380 Posted October 3 Plain text CSV is my prefered format. I would make each line with details specific to an item. Order of cells in a line would be in the importance to compare them. Sort the whole file alpabétically at the end. Use WinMerge utility to quickly compare the files. Write a dedicated software to read the CSV and make more complex comparison if needed. Example of a line syntax: Storage, HardDisk, SerialNumber, BrandAndModel, Capacity Example of an actual line: Storage, HardDisk, 22RKKA0, WDC WD10EZEX, 953667MB 1 Share this post Link to post
Die Holländer 45 Posted October 3 <?xml version="1.0" encoding="UTF-8"?> <PCConfiguration> <System> <Brand>Custom Build</Brand> <Model>Gaming Rig</Model> <DateAssembled>2023-10-15</DateAssembled> </System> <Hardware> <CPU> <Model>AMD Ryzen 9 5900X</Model> <Cores>12</Cores> <Threads>24</Threads> <BaseClock>3.7 GHz</BaseClock> <BoostClock>4.8 GHz</BoostClock> </CPU> <Motherboard> <Brand>ASUS</Brand> <Model>ROG Strix X570-E Gaming</Model> <FormFactor>ATX</FormFactor> <Chipset>AMD X570</Chipset> </Motherboard> <RAM> <TotalCapacity>32 GB</TotalCapacity> <Type>DDR4</Type> <Speed>3200 MHz</Speed> <Modules> <Module> <Capacity>16 GB</Capacity> <Brand>Corsair</Brand> <Model>Vengeance LPX</Model> </Module> <Module> <Capacity>16 GB</Capacity> <Brand>Corsair</Brand> <Model>Vengeance LPX</Model> </Module> </Modules> </RAM> <Storage> <Drives> <Drive> <Type>SSD</Type> <Capacity>1 TB</Capacity> <Brand>Samsung</Brand> <Model>970 EVO Plus</Model> </Drive> <Drive> <Type>HDD</Type> <Capacity>2 TB</Capacity> <Brand>Western Digital</Brand> <Model>Blue</Model> </Drive> </Drives> </Storage> <GraphicsCard> <Brand>NVIDIA</Brand> <Model>GeForce RTX 3080</Model> <Memory>10 GB</Memory> <Type>GDDR6X</Type> </GraphicsCard> </Hardware> <Peripherals> <Monitor> <Brand>Dell</Brand> <Model>U2720Q</Model> <Size>27 inches</Size> <Resolution>3840 x 2160</Resolution> </Monitor> <Keyboard> <Brand>Logitech</Brand> <Model>G915</Model> <Type>Mechanical</Type> </Keyboard> <Mouse> <Brand>Razer</Brand> <Model>DeathAdder V2</Model> <Type>Wired</Type> </Mouse> </Peripherals> </PCConfiguration> 1 Share this post Link to post
corneliusdavid 213 Posted October 3 I'd be tempted to throw it in a small SQLite database. You could add date/time stamp and add to it over time, then even do queries on it to see history of specific changes or compare with other systems. Then again, maybe that's overkill. 1 Share this post Link to post
Shrinavat 16 Posted October 4 21 hours ago, FPiette said: Plain text CSV is my prefered format. Thank you for the suggestion! Using a sorted CSV file with a dedicated comparison tool sounds like a very interesting and potentially robust approach. I'll definitely explore this option further. 19 hours ago, Die Holländer said: <?xml version="1.0" encoding="UTF-8"?> Thanks for sharing the XML example. I'm already familiar with saving the configuration in XML format 🙂. However, my main challenge lies in efficiently comparing two XML files to identify meaningful changes. I'm open to suggestions on how to best approach this comparison aspect. 16 hours ago, corneliusdavid said: I'd be tempted to throw it in a small SQLite database. That's an interesting idea using SQLite. My main concern with a database approach is the unknown and variable number of fields. I'm not sure how to design the database structure to accommodate this and still allow for easy comparison between different snapshots. Could you elaborate on how you envision structuring the database to handle this dynamic nature and facilitate efficient comparisons? Share this post Link to post
FPiette 380 Posted October 4 3 hours ago, Shrinavat said: Thank you for the suggestion! Using a sorted CSV file with a dedicated comparison tool sounds like a very interesting and potentially robust approach. I'll definitely explore this option further. Sorted CSV is an easy way to handle comparison you need. And if more advanced comparison is required, you may load the CSV in a SQL database (maybe SQLite) or even use a spreadsheet like Excel if you are comfortable with VBA. Excel can directly load CSV files. Of course you can write your analysis in pure Delphi. You'll easily find a library to load a CSV file in an array in memory. What you shall use depends on your preferences and skills. 1 Share this post Link to post
corneliusdavid 213 Posted October 4 7 hours ago, Shrinavat said: My main concern with a database approach is the unknown and variable number of fields. I'm not sure how to design the database structure to accommodate this and still allow for easy comparison between different snapshots. Could you elaborate on how you envision structuring the database to handle this dynamic nature and facilitate efficient comparisons? Your record structure would have a lot of string fields, one for each possible type of data you want to save; it'd also have a DateTime field so you could record when the snapshot of your system was taken. The key is to be consistent in how you store the data; for example, the network adapter information should always be stored in the same field(s) requiring some way of identifying them (or lumping all network adapters in one big memo field, perhaps). I'd probably create a detail table for some fields, like the storage section in your screen-shot above. You could have a field for GUID to identify each disk and then the main table would have a summary of how many disks and the total GB. You could use something like Mitec System Information components to scan your computer every time it booted up and if something changed, add an entry to your database with a new date/time stamp. Later, you could go through and see various changes over time as you scan the records. You could also filter on certain fields to see when something changed. It's really important that you evaluate what and how often your data will change and what you want to do with it later. If this is a product you're building for others, definitely store it in a database; if it's just a one-time information gathering tool for your self over the next six months as your play around with different hardware configurations, just manually enter stuff into a spreadsheet. It really depends on your usage requirements and how much time you have. 1 Share this post Link to post
dormky 2 Posted October 11 Doing a file-based comparison will always lead you into problems where something changes, but it's not something that actually impact the configuration in real-life. Better to write code to handle the comparison. If you really don't want to do that, you need empty spaces ie reserve 30 lines for drives and when saving, always sort alphabetically. Each field would have a specific length so no offset changes. But it's going to be a pain. Maybe separate the data you actually want to compare ; even in a single file you can have a marker like a line of '|' after which the data resides and you have a very small script to compare that part of the file and not the rest. 1 Share this post Link to post