Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Dave Kreskowiak2-Nov-23 4:09
mveDave Kreskowiak2-Nov-23 4:09 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Pete O'Hanlon2-Nov-23 3:45
mvePete O'Hanlon2-Nov-23 3:45 
AnswerRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
jschell19-Oct-23 5:08
jschell19-Oct-23 5:08 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Tridip Bhattacharjee from Unknown26-Oct-23 10:45
Tridip Bhattacharjee from Unknown26-Oct-23 10:45 
Questionmysql db in cloud with c# desktop application geting too slow Pin
Member 1103383418-Oct-23 6:35
Member 1103383418-Oct-23 6:35 
AnswerRe: mysql db in cloud with c# desktop application geting too slow Pin
jeron118-Oct-23 7:25
jeron118-Oct-23 7:25 
AnswerRe: mysql db in cloud with c# desktop application geting too slow Pin
Dave Kreskowiak18-Oct-23 8:38
mveDave Kreskowiak18-Oct-23 8:38 
AnswerRe: mysql db in cloud with c# desktop application geting too slow Pin
jschell19-Oct-23 5:11
jschell19-Oct-23 5:11 
QuestionNeed to create next button Pin
Member 1611639316-Oct-23 4:26
Member 1611639316-Oct-23 4:26 
AnswerRe: Need to create next button Pin
Gerry Schmitz16-Oct-23 5:16
mveGerry Schmitz16-Oct-23 5:16 
GeneralRe: Need to create next button Pin
Member 1611639316-Oct-23 6:17
Member 1611639316-Oct-23 6:17 
GeneralRe: Need to create next button Pin
Dave Kreskowiak16-Oct-23 7:19
mveDave Kreskowiak16-Oct-23 7:19 
AnswerRe: Need to create next button Pin
RedDk16-Oct-23 6:49
RedDk16-Oct-23 6:49 
QuestionTransfer data between MFC Application and c# application using NamedPipe Pin
manoharbalu13-Oct-23 1:37
manoharbalu13-Oct-23 1:37 
AnswerRe: Transfer data between MFC Application and c# application using NamedPipe Pin
Richard Andrew x6413-Oct-23 2:28
professionalRichard Andrew x6413-Oct-23 2:28 
AnswerRe: Transfer data between MFC Application and c# application using NamedPipe Pin
JudyL_MD13-Oct-23 5:05
JudyL_MD13-Oct-23 5:05 
QuestionCreating a JSON File from a CSV file in C# Pin
Member 1611347712-Oct-23 2:19
Member 1611347712-Oct-23 2:19 
Apologies but this is going to be a "How to" question rather than a technical question. I am very new to C# and using Json. I have a CSV file as follows:

Edit - I did manage to find some code here - https://qawithexperts.com/article/c-sharp/convert-csv-to-json-in-c/465 - not sure if this is suitable for my goal as it seems to be a simple convert.

    Time	         Control_Code	Metric	Organisation	Value	DateTime
 

    2018-10-21T00:08:03 JKX           3721      AD450          20   2018-10-21T00:08:00
    2018-10-21T00:08:03 BHY           1234      HG650          88   2018-10-21T00:08:00
I need to produce multiple JSON output files from that csv in the following format example:

    {
        "Time":"2018-10-21T00:08:03",
        "Control_Code": "JKX",
        "metrics": [
            {
                "Metric": 3721,
                "Organisation":"AD450",
                "Value": 20,
                "Datetime":"2018-10-21T00:08:00"
            },
            {
                "Metric": 1234,
                "Organisation":"HG650",
                "value": 88,
                "datetime":"2018-10-21T00:08:00"
            }
            
        ]
    }

Now the extra problematic part on top of this is that there is a requirement where only one Control_Code may be used per Json.
Each Json generated must contain a single Control_Code and all related metric values in the metrics array. So the csv will need to be scanned for each different Control_Code and then produce an output for that specific Control_Code and then do the same for any subsequent Control_Codes.

So for example a different Json would be produced with a different Control_Code (from the same csv file) - Example (notice different Control_Code other values will of course change as well, but just providing an example).

    {
        "Time":"2018-10-21T00:08:03",
        "Control_Code": "BHY",
        "metrics": [
            {
                "Metric": 3721,
                "Organisation":"AD450",
                "Value": 20,
                "Datetime":"2018-10-21T00:08:00"
            },
            {
                "Metric": 1234,
                "Organisation":"HG650",
                "value": 88,
                "datetime":"2018-10-21T00:08:00"
            }
            
        ]
    }

Thanks for any advice/information in advance.

AnswerRe: Creating a JSON File from a CSV file in C# Pin
OriginalGriff12-Oct-23 2:29
mveOriginalGriff12-Oct-23 2:29 
AnswerRe: Creating a JSON File from a CSV file in C# Pin
jschell12-Oct-23 5:17
jschell12-Oct-23 5:17 
AnswerRe: Creating a JSON File from a CSV file in C# Pin
Gerry Schmitz12-Oct-23 8:36
mveGerry Schmitz12-Oct-23 8:36 
GeneralRe: Creating a JSON File from a CSV file in C# Pin
OriginalGriff12-Oct-23 9:07
mveOriginalGriff12-Oct-23 9:07 
GeneralRe: Creating a JSON File from a CSV file in C# Pin
Gerry Schmitz12-Oct-23 9:28
mveGerry Schmitz12-Oct-23 9:28 
GeneralRe: Creating a JSON File from a CSV file in C# Pin
OriginalGriff12-Oct-23 10:20
mveOriginalGriff12-Oct-23 10:20 
GeneralRe: Creating a JSON File from a CSV file in C# Pin
jschell13-Oct-23 7:09
jschell13-Oct-23 7:09 
QuestionItemObservableCollection Pin
rex648-Oct-23 7:34
rex648-Oct-23 7:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.