Hi i have a container that has multiple records (lines)
I want to be able to send it to azure blob as csv
I'm assuming i need to convert the container to sth that can be accepted by azure blob
So what should i do exactly?
Hi i have a container that has multiple records (lines)
I want to be able to send it to azure blob as csv
I'm assuming i need to convert the container to sth that can be accepted by azure blob
So what should i do exactly?
You said that the result is correct, therefore there is nothing wrong with your code, if it generates correct results.
Your only problem is in how Excel interprets your data by default. You can explicitly tell it how it should do it - use Data > From Text/CSV in Excel for this purpose.
Maybe the problem is in the value separator. Maybe you're trying to import the file on a system configured with semicolon as the list separator, and changing your format would allow Excel to interpret it correctly by default. But it would stop working in systems configured in a different way.
Hi Martin,
When i open the csv file i see a weird result
when i open it in notepad the result is correct
Example:
"200","2009.243","-11.3","33"
However, when i open it in excel
i'm expecting it to be filled in one column like this
200,"2009.243","-11.3","33"
but currently it's filling each number in a different column
is this related to excel or related to my code?
Thanks Martin,
Would u mind looking at this question? (it's related to azure blob)
Thanks Martin
Good! It seems that the problem is resolved. Please don't forget verify answer(s).
By the way, you can greatly simplify your code by utilizing the 'using' statement. Like this:
using System.IO; using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Blob; class MyClass { void export() { container lines; CommaStreamIo comma = CommaStreamIo::constructForWrite(); comma.outFieldDelimiter(','); str fileName = 'Test.csv'; comma.writeExp(lines); // assume lines is filled Stream stream = comma.getStream(); stream.Position = 0; StorageCredentials storageCredentials = new StorageCredentials(StorageAccountName, StorageKey); CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, true); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer cont = blobClient.GetContainerReference(BlobContainer); CloudBlockBlob cloudBlockBlob = cont.GetBlockBlobReference(fileName); cloudBlockBlob.UploadFromStream(stream, null, null, null); } }
Hi Matrin,
Thanks alot. yeah my container has string values.
What i did is, while filling each container i used commaStreamIo write method and i was able to receive the file successfully to azure blob ( it was a quick test).
Here's what i did:
contianer lines; CommaStreamIo comma = CommaStreamIo::constructForWrite(); comma.outFieldDelimiter(","); str fileName = "Test.csv" comma.writeExp(lines); // assume lines is filled System.IO.Stream stream = comma.getStream(); Microsoft.WindowsAzure.Storage.Auth.StorageCredentials storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(StorageAccountName, StorageKey); Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true); var blobcli = storageAccount.CreateCloudBlobClient(); Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer cont = blobcli.GetContainerReference(BlobContainer); stream.Position=0; Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob cloudBlockBlob = cont.GetBlockBlobReference(fileName); cloudBlockBlob.UploadFromStream(stream,null,null,null);
Please remember that I still don't know what you have in the container, therefore I can't say much about how you should process it. I can only assume that you want to do something with each element, therefore you'll indeed need to iterate the container to get elements one by one. But if you just wanted to create lines (because you already have lines content ready), you could do that with con2str(). Or maybe you have something else is in the container and you need to do something completely different.
Why do you want to "see the file"? I thought you want to write it to a blog, not to display it.
CommaStreamIO writes data to a stream, which you can pass to CloudBlockBlob.UploadFromStream(), for example. CommaTextIo writes to a file on disk.
Hi Martin,
In ax12, the old service used commaTextIo
By using the method Write and passing container to it.
What should i do to see the file after using write method?
Also what's the difference between using commaTextIo and CommaStreamIo?
Hi martin,
No i didn't overlook it. By saying streamIo.. I mean commaStreamIo.
So when u mentioned it i read about it.
My question was should i loop through the container? Or is there a way i can pass the container and it will convert it to CSV?
Yes, it is possible. You seemed to overlook my suggestion: CommaStreamIo class.
André Arnaud de Cal... 291,391 Super User 2024 Season 2
Martin Dráb 230,445 Most Valuable Professional
nmaenpaa 101,156