in Education by
I'm trying to write an Azure table Storage Query result to a .csv file and store it locally on the machine (temp is fine). I'm able to query without issue - then display the results in a messageBox. I'm doing this using c#. I don't want to use an external application, but will call on a powershell script if that is what it takes. Ultimately, I'm trying to download the csv so I query the csv file instead of azure tables storage for more functionality. (SQL Server isn't an option at this time - although I do understand it would make my life so much easier) CloudStorageAccount storageAccount = CloudStorageAccount.Parse ("DefaultEndpointsProtocol=https;AccountName=MyStorageAccountNameHere;AccountKey=MyTableKeyhere CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("TelephonyIssueLog"); var managerQuery = new TableQuery().Where(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, "Issues")); System.IO.File.WriteAllText(@"C:\temp\csv.csv", managerQuery); JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I actually figured it out: starting with the top using CsvHelper; if (string.IsNullOrEmpty(txtFirstN.Text) || string.IsNullOrEmpty(txtLName.Text) || string.IsNullOrEmpty(cbDirection.Text) || string.IsNullOrEmpty(cbPhoneSystem.Text) || string.IsNullOrEmpty(txtCustPhone.Text) || string.IsNullOrEmpty(txtManager.Text) || string.IsNullOrEmpty(txtProgram.Text) || string.IsNullOrEmpty(cbLocation.Text) || string.IsNullOrEmpty(txtPhoneNumber.Text) || string.IsNullOrEmpty(cbIssue.Text) || string.IsNullOrEmpty(cbPhoneSystem.Text)) { MessageBox.Show("Please Fill out the WHOLE Form. Thank you!"); } else { CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=myaccountname;AccountKey=my-account-key CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("TelephonyIssueLog"); //Await is a good command to use here so we don't try to go forward before we verify the table actually exists and error out. //Notice I made the function async. C# is annoying as all out when using async and await so yeah have fun with that :D. -=Chris await table.CreateIfNotExistsAsync(); IssueEntity IssueLog = new IssueEntity("Issues", lblRandom.Text); IssueLog.FirstName = txtFirstN.Text; IssueLog.LastName = txtLName.Text; IssueLog.CallDirection = cbDirection.Text; IssueLog.CustNumber = txtCustPhone.Text; //IssueLog.FirstName = tbFirstName.Text; //IssueLog.LastName = tbLastName.Text; IssueLog.Location = cbLocation.Text; IssueLog.Manager = txtManager.Text; IssueLog.PhoneNumber = txtPhoneNumber.Text; IssueLog.PhoneSystem = cbPhoneSystem.Text; IssueLog.PrimaryIssue = cbIssue.Text; IssueLog.Program = txtProgram.Text; TableOperation insertOperation = TableOperation.Insert(IssueLog); table.Execute(insertOperation); Then, comes the query and CSV Edit: //get to the cloud storage CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=my-account-name;AccountKey=My-Account-Key CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("TelephonyIssueLog"); Worked like a charm! //initiate the writer var sw = new StreamWriter(@"C:\ProgramData\N3RASupportNotifier\Test.csv"); var writer = new CsvWriter(sw); TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Issues")); //Write each record to CSV foreach (IssueEntity entity in table.ExecuteQuery(query)) { writer.WriteField(entity.FirstName); writer.WriteField(entity.LastName); writer.WriteField(entity.Location); writer.WriteField(entity.Manager); writer.WriteField(entity.PartitionKey); writer.WriteField(entity.PhoneSystem); writer.WriteField(entity.PrimaryIssue); writer.WriteField(entity.Timestamp); writer.NextRecord(); }

Related questions

0 votes
    Is there an easy way to run a MySQL query from the Linux command line and output the results in CSV format? Here's what I'm doing now: mysql -u uid -ppwd -D dbname...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I want to put my Results of a hiveql query into a CSV file. How can I do it? I tried doing this, but ... select goods from the table; Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Unlike writing out a table or CSV file, dump() and dput() preserve the ______ so that another user ... Operations of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    i have one csv file which contains library group and it's data... group consider as sheet and for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 16, 2022 in Education by JackTerrance
0 votes
    COPY TO exports data from a csv into table (1)False (2)True...
asked Apr 17, 2021 in Technology by JackTerrance
0 votes
    Azure Traffic manager receives a query from _____________. A. Endpoint B. Client C. Routing Method D. All the options...
asked Nov 21, 2022 in Education by JackTerrance
0 votes
    I have an ASP.NET MVC website. In my backend I have a table called People with the following ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I need to take the users input from the select box for Allergen1 once an option is selected and the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I need to perform a query to limit the rows displayed in a table. I chose QTableView/QSqlTableModel for ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I have 2 entity: /** * @ORM\Entity * @ORM\Table(name="users") */ class User { /** * ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have this table where columns correspond to names: i.e. 11 = first, 12 = second, 13 = third.. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 15, 2022 in Education by JackTerrance
0 votes
    In Ms Access Which query allow to create a table or alter data or database? Select the correct answer from above options...
asked Dec 17, 2021 in Education by JackTerrance
0 votes
    A_____ is a query that retrieves rows from more than one table or view: (a) Start (b) End (c ... Join Operations topic in chapter Query Processing Techniques of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    I have an Azure table datastore and here's my model for one class: public class Product : ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    I am trying to run the following SQL: INSERT INTO Suppliers ( [SupplierID], [CompanyName]) Select [SupplierID], [ ... is very slow. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
...