CodedUI test does not read data from CSV input file - csv

I am having difficulty mapping a CSV file with the Coded UI test method. This is most likely a stupid question but I cannot seem to find a solution for my problem, at least not one that works. I have made sure to set the property of the CSV file to Copy always.
I have also imported the CSV file by writing the following line above the test method.
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\Data\\login.csv", "login#csv", DataAccessMethod.Sequential), DeploymentItem("login.csv"), TestMethod]
The file name is login.csv and it resides in the Data folder.
The test will compile without any problem but once the test executes the fields that should receive input from the CSV file are left empty and the execution is interrupted. I've tried replacing the data from the CSV file by using Strings and it works perfectly fine. The piece of code I am using to import each parameter is:
TestContext.DataRow["Username"].ToString()
Also, the CSV file contains something along the following lines:
Username,Password,Fullname
admin#mail.com,password,Admin
Is there anyone who can point what it is I am forgetting.
Update: I pinpointed the issue, it seems like the issue only revolves around the first column in the csv file. When I try to import any of the other values it works perfectly fine.

Some text files start with a Byte Order Mark (BOM). The CSV reader within Coded UI does not handle the BOM and treats it as part of the first field name. The screen shot below shows the debug trace of a CSV file with a BOM and that same file shown in Notepad++. The DataRow.ItemArray[...] values are as expected. The DataRow.Table.Columns.ResultsView[...] shows the field names, but the first field name includes the BOM.
This CSV file with a BOM was created in Visual Studio using Solution Explorer => Add => New item => C# => General => Text file. Previously I have created a spread sheet with Microsoft Excel and saved it as a CSV file, that file did not have a BOM. I have also created files with Notepad++ and saved as CSV and they did not have a BOM. It appears that Visual Studio creates files with a BOM but when editing CSV files it does not add a BOM.
Visual Studio can create files with the correct encoding. Within "Step 2 - Create a data set" of this Microsoft page it states the text below. (Thanks also to Holistic Developer for providing very similar details in a comment.):
It is important to save the .csv file using the correct encoding. On the FILE menu, choose Advanced Save Options and choose Unicode
(UTF-8 without signature) – Codepage 65001 as the encoding.

For Visaul Studio 2010, i could solve issue be selecting "Western European (Windows) - Codepage 1252" encoding for CSV files.
Summary of steps:
In visual studio 2010, Open CSV file > Go to File menu > Select " Advanced Save Options" > Select "Western European (Windows) - Codepage 1252" > Save.
This should help.

This is not the best solution but its kind of a workaround. I simply set the first element to something random and since I don't need access to the first element it doesn't matter that I don't have access to it.
If anyone finds a correct way to solve this problem I'd be grateful for your solution.

Related

Here XYZ Studio issue with uploading files

It seems that the XYZ Studio has some problems with accepting files. The upload of .geojson and .csv files is recommended but it tells me i am trying to upload "unsupported file types". It still worked a few weeks ago but i cannot upload any .geojson and .csv files right now.
Kindly crosscheck the names in the header of your csv file. If the file does not have columns labelled Latitude and Longitude, the xyz studio may give you a message saying that you are trying to upload an unsupported file.
I ran into a similar issue. Turns out HERE Studio prefers comma (,) CSVs only. If modifying in excel and it gets saved as a caret (^) CSV, the uploader will only read the file as one wide column and pop out errors.
If HERE is listening, some documentation on properly formatted file types, formats, and limitations along with sample code for the .CSVs, json, shape, and GEOjson files would be immensely helpful to users of Studio as there is little in the way on the API/platform documentation.

Magento 2.1.1 We can't find required columns: sku

My apologies if a solution has been provided elsewhere. I have searched and could not find anything similar to what I am experiencing. I am trying to upload categories on a Magento CE 2.1.1 website. I have a file with almost 4000 categories and sub categories and the only practical way is to upload via a csv file.
I downloaded a sample file to use and when I upload the same sample file it's working fine when I click Check data" button. However, when I replace the values on the rows with my own and save the file as csv with UTF-8 text encoding, I am getting an error message below. This is also happening when I save the file as csv even without changing the values. I have tested this with a csv file saved from both Mac Numbers and Windows Excel.
I only need to upload Categories (and not products) but I am not sure if this is possible.
File links:
Importing
Not importing
Actual project sample file
The files are quite similar but strangely one is working and the other is not.
Error
We can't find required columns: sku.
Column names: "sku;store_view_code;attribute_set_code;product_type;categories;product_websites;name;description;short_description;weight;product_online;tax_class_name;visibility;price;special_price;special_price_from_date;special_price_to_date;url_key;meta_title;meta_keywords;meta_description;base_image;base_image_label;small_image;small_image_label;thumbnail_image;thumbnail_image_label;swatch_image;swatch_image_label;created_at;updated_at;new_from_date;new_to_date;display_product_options_in;map_price;msrp_price;map_enabled;gift_message_available;custom_design;custom_design_from;custom_design_to;custom_layout_update;page_layout;product_options_container;msrp_display_actual_price_type;country_of_manufacture;additional_attributes;qty;out_of_stock_qty;use_config_min_qty;is_qty_decimal;allow_backorders;use_config_backorders;min_cart_qty;use_config_min_sale_qty;max_cart_qty;use_config_max_sale_qty;is_in_stock;notify_on_stock_below;use_config_notify_stock_qty;manage_stock;use_config_manage_stock;use_config_qty_increments;qty_increments;use_config_enable_qty_inc;enable_qty_increments;is_decimal_divided;website_id;related_skus;related_position;crosssell_skus;crosssell_position;upsell_skus;upsell_position;additional_images;additional_image_labels;hide_from_product_page;bundle_price_type;bundle_sku_type;bundle_price_view;bundle_weight_type;bundle_values;bundle_shipment_type;associated_skus" are invalid
This might be because you opened the file in Excel which will add a BOM to the start of the file. When the Magento importer tries to read the file, it expects the first header/cell to say sku, but it instead sees the BOM.
Two ways to solve this:
1) Don't open it in excel - use Google sheets, or a text editor if you are feeling brave,
2) If you opened the file in excel, close it, open it in notepad++, click encoding up the top and set to "Encode in UTF-8" (NOT "Encode in UTF-8-BOM"). Then save and you are good to go.

Text encoding for sound recording copyright symbol in a .tsv file

I'm having an issue where I can't get this symbol "℗" to render in a .tsv file. I'm using powershell to add data to my .tsv that has copyright info, so I need to have it copy over correctly. I use add-content -path C:\blah and I include the -encoding parameter at the end, but all of the encoding choices I've tried cannot render this sound recording copyright symbol. Anyone have any idea if this can work? UTF8 and UTF32 render the © symbol correctly, for what it's worth. What's also sort of funny is that Powershell ISE can render the symbol correctly.
Thanks for any help.
Edit: I'm thinking now it may just be a limitation of the .tsv file? I just tried opening the .tsv in excel, pasting the "℗" symbol into an empty cell, and when I save and re-open the file, the "℗" is replaced by a "?".
Edit 2: If I use import-csv -path -delimiter and import the .tsv, the symbol does render correctly in Powershell. I would like it to render correctly in Excel if that's possible. I also tried to load it using Google Sheets but it had the same problem.
This turns out to be sort of a workaround I think, but the end result is what I wanted.
There seems to be some type of problem with excel and the encoding of .tsv, .csv, etc. So what I found worked for me was opening whatever file I wanted (in Excel), saving as a "Unicode .txt", then just renaming the file extension from .txt to .tsv. The file still opens correctly as a .tsv spreadsheet, but for whatever reason the encoding works now so that the "℗" saves correctly. And it looks like I only need to do this once and I can keep appending to the same .tsv. Strange solution, but I'll take it.
And just to clarify, if I open the file as a .txt in Excel, it also retains the correct formatting. I just changed the extension to .tsv so that a double click will open to Excel rather than notepad. I believe the file is technically still saved as a Unicode .txt file.

"Inconsistent number of matrix lines compared to the number of labels" runtime exception error when importing large CSV file into Gephi

The full error is "java.lang.RuntimeException: java.lang.Exception: Inconsistent number of matrix lines compared to the number of labels."
I am trying to pull an adjacency matrix stored in a CSV file into Gephi so that I can use its modularity optimization tool and make a really slick chart of my data. I compiled the data in Excel (yes, it took forever) and saved it as CSV, and then I opened the file in Notepad and used Ctrl + H to replace all commas with semicolons (and saved it as a CSV file again). My dataset is 5,654 x 5,654 cells, not counting the labels. It is an r-neighborhood graph with r = .6299 (80th percentile and above).
I searched Google and StackOverflow and I only found one solution for my error message: to remove all the spaces in the file. I used Ctrl + H again to remove all spaces, but I received the same error message when I tried to upload the "spaceless" CSV file. Just to double-check that saving it as CSV didn't cause an issue, I checked the CSV by opening it up in Excel. The file opened correctly, but I do not have much experience with CSV files so I do not know if anything was off. It seemed as though all the records were separated by semicolons instead of commas and I did not see any spaces.
Is it the size of my file? I am currently struggling through learning some Python and R, and I would be open to creating this adjacency matrix CSV file in either of those environments and then feeding it to Gephi. I just need a dependable solution that works without bogging my computer down in Excel all afternoon and allows me to be the "slick graph superhero" of my office.
Not a direct answer to your problem but there is also the Excel/CSV import spigot to whatever it might be useful. Otherwise you could perhaps try to import the network with NodeXL and then save it in GraphML format which can then be opened by Gephi
Good tip from http://social-dynamics.org/gephi-faq/
A. One thing to try is removing any extra spaces from your csv file.
Sometimes these trip up the import. Open the csv file using a simple
text editor like NotePad or TextEdit, and then use find/replace to
remove any spaces. Save the adjacency matrix and then try importing it
again.
Removing spaces helped me to fix the issue.

CSV File showing random characteristics

I copied a file from my ipad using iFunBox and I tried opened it with:
Microsoft Excel
FreeFileViewer
Notepad
Notepad++
All of them shown nothing File (.csv) Everytime open it using those 4 programmes this is what I get:
] 1 ˆ&ÓMF.¶•J¡ ñßR)åÙ¥e
ò¦Øœsl\V{`¸u°N±vI¦½™êk4“‡-m Ùò¾ˆÚär'²ø¢å:š nàÊ#‹8yH#uä³éc‹übuÙÀÙHIˆ[g¿^¶$9¹asï³`‰;*ý:Ôê]ÓlÆFJŠzÆy l[
†nÒdzÙ› ™uê^ï:—ŽœÏ·`ð€‡°XR…Hù™6è³ß×+¥Û/‹ÐÉÞ‡çååw¿öùr~uóçˆKÝcýœó©û$R0áÓ)`´Á°ŠOŸ¸hÉw”ÕÌ$¾S|åÚ†G¾Ùú¿#/¯J(Ádž‡Úøo䇙ñyŠÃ©A°6ÀÊ¿©þFDBº·SáóDEa±€o¹Nê¦ä~iÿñÍQ‹òÊun¢ç,Æâðe IéŒ
The file seems to be binary and not CSV. CSV is a plain text file which depending on the text encoding may show some strange characters, but mainly plainly readable. The file above is a kind of OMF file, whatever that is.