Loading a CSV file and accessing the variables
Hi guys,
I'm new to AS3 and dealt with AS2 before (just getting the grasp when the change it).
Is it possible in AS3 to load an excel .csv file into Flash using the URLLoader (or ???) and the data as variables?
I can get the .csv to load and trace the values (cell1,cell2,cell3....) but I'm not sure how to collect the data and place it into variables.
Can I just create an array and access it like so.... myArray[0], myArray[1]? If so, I'm not sure why it's not working.
I must be on the completely wrong path. Here's what I have so far....
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, dataLoaded);
var request:URLRequest = new URLRequest("population.csv");
loader.load(request);
function dataLoaded(evt:Event):void {
var myData:Array = new Array(loader.data);
trace(myData[i]);
Thanks for any help,
Sky
just load your csv file and use the flash string methods to allocate those values to an array:
var myDate:Array = loader.data.split(",");
Similar Messages
-
Loop through a csv file and return the number of rows in it?
What would be simplest way to loop through a csv file and
return the number of rows in it?
<cffile action="read" file="#filename#" output="#csvstr#"
>
<LOOP THROUGH AND COUNT ROWS>ListLen(). Use chr(13) as your delimiter
-
Read a csv file and read the fiscal yr in the 4th pos?
Hello ABAP Experts,
how to write a code for read a csv file and read the fiscal year in the 4th position.
any suggestions or code highly appreciated.
Thanks,
BWerHi Bwer,
Declare table itab with the required fields...
Use GUI UPLOAD to get the contents of the file (say abc.csv) in case if the file is on the presentation server...
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'c:\abc.csv'
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
tables
data_tab = itab
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Use OPEN DATASET in case if the file is on the application server..
After that USE SPLIT command at comma to get the contents of the 4th field...
Regards,
Tanveer.
<b>Please mark helpful answers</b> -
// Code Help need .. in Reading CSV file and display the Output.
Hi All,
I am a new Bee in code and started learning code, I have stared with Console application and need your advice and suggestion.
I want to write a code which read the input from the CSV file and display the output in console application combination of first name and lastname append with the name of the collage in village
The example of CSV file is
Firstname,LastName
Happy,Coding
Learn,C#
I want to display the output as
HappyCodingXYZCollage
LearnC#XYXCollage
The below is the code I have tried so far.
// .Reading a CSV
var reader = new StreamReader(File.OpenRead(@"D:\Users\RajaVill\Desktop\C#\input.csv"));
List<string> listA = new List<string>();
while (!reader.EndOfStream)
var line = reader.ReadLine();
string[] values = line.Split(',');
listA.Add(values[0]);
listA.Add(values[1]);
listA.Add(values[2]);
// listB.Add(values[1]);
foreach (string str in listA)
//StreamWriter writer = new StreamWriter(File.OpenWrite(@"D:\\suman.txt"));
Console.WriteLine("the value is {0}", str);
Console.ReadLine();
Kindly advice and let me know, How to read the column header of the CSV file. so I can apply my logic the display combination of firstname,lastname and name of the collage
Best Regards,
Raja Village Sync
Beginer CoderVery simple example:
var column1 = new List<string>();
var column2 = new List<string>();
using (var rd = new StreamReader("filename.csv"))
while (!rd.EndOfStream)
var splits = rd.ReadLine().Split(';');
column1.Add(splits[0]);
column2.Add(splits[1]);
// print column1
Console.WriteLine("Column 1:");
foreach (var element in column1)
Console.WriteLine(element);
// print column2
Console.WriteLine("Column 2:");
foreach (var element in column2)
Console.WriteLine(element);
Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP] -
How to Compare 2 CSV file and store the result to 3rd csv file using PowerShell script?
I want to do the below task using powershell script only.
I have 2 csv files and I want to compare those two files and I want to store the comparision result to 3rd csv file. Please look at the follwingsnap:
This image is csv file only.
Could you please any one help me.
Thanks in advance.
By
A Path finder
JoSwa
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"
Best Online JournalNot certain this is what you're after, but this :
#import the contents of both csv files
$dbexcel=import-csv c:\dbexcel.csv
$liveexcel=import-csv C:\liveexcel.csv
#prepare the output csv and create the headers
$outputexcel="c:\outputexcel.csv"
$outputline="Name,Connection Status,Version,DbExcel,LiveExcel"
$outputline | out-file $outputexcel
#Loop through each record based on the number of records (assuming equal number in both files)
for ($i=0; $i -le $dbexcel.Length-1;$i++)
# Assign the yes / null values to equal the word equivalent
if ($dbexcel.isavail[$i] -eq "yes") {$dbavail="Available"} else {$dbavail="Unavailable"}
if ($liveexcel.isavail[$i] -eq "yes") {$liveavail="Available"} else {$liveavail="Unavailable"}
#create the live of csv content from the two input csv files
$outputline=$dbexcel.name[$i] + "," + $liveexcel.'connection status'[$i] + "," + $dbexcel.version[$i] + "," + $dbavail + "," + $liveavail
#output that line to the csv file
$outputline | out-file $outputexcel -Append
should do what you're looking for, or give you enough to edit it to your exact need.
I've assumed that the dbexcel.csv and liveexcel.csv files live in the root of c:\ for this, that they include the header information, and that the outputexcel.csv file will be saved to the same place (including headers). -
Memory problem with loading a csv file and displaying 2 xy graphs
Hi there, i'm having some memory issues with this little program.
What i'm trying to do is reading a .csv file of 215 mb (6 million lines more or less), extracting the x-y values as 1d array and displaying them in 2 xy graphs (vi attacked).
I've noticed that this process eats from 1.6 to 2 gb of ram and the 2 x-y graphs, as soon as they are loaded (2 minutes more or less) are really realy slow to move with the scrollbar.
My question is: Is there a way for use less memory resources and make the graphs move smoother ?
Thanks in advance,
Ierman Gert
Attachments:
read from file test.vi 106 KBHi lerman,
how many datapoints do you need to handle? How many do you display on the graphs?
Some notes:
- Each graph has its own data buffer. So all data wired to the graph will be buffered again in memory. When wiring a (big) 1d array to the graph a copy will be made in memory. And you mentioned 2 graphs...
- load the array in parts: read a number of lines, parse them to arrays as before (maybe using "spreadsheet string to array"?), finally append the parts to build the big array (may lead to memory problems too).
- avoid datacopies when handling big arrays. You can show buffer creation using menu->tools->advanced->show buffer allocation
- use SGL instead of DBL when possible...
Message Edited by GerdW on 05-12-2009 10:02 PM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Read two CSV files and remove the duplicate values within them.
Hi,
I want to read two CSV files(which contains more than 100 rows and 100 columns) and remove the duplicate values within that two files and merge all the unique values and display it as a single file.
Can anyone help me out.
Thanks in advance.kirthi wrote:
Can you help me....Yeah, I've just finished... Here's a skeleton of my solution.
The first thing I think you should do is write a line-parser which splits your input data up into fields, and test it.
Then fill out the below parse method, and test it with that debugPrint method.
Then go to work on the print method.
I can help a bit along the way, but if you want to do this then you have to do it yourself. I'm not going to do it for you.
Cheers. Keith.
package forums.kirthi;
import java.util.*;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import krc.utilz.io.ParseException;
import krc.utilz.io.Filez.LineParser;
import krc.utilz.io.Filez.CsvLineParser;
public class DistinctColumnValuesFromCsvFiles
public static void main(String[] args) {
if (args.length==0) args = new String[] {"input1.csv", "input2.csv"};
try {
// data is a Map of ColumnNames to Sets-Of-Values
Map<String,Set<String>> data = new HashMap<String,Set<String>>();
// add the contents of each file to the data
for ( String filename : args ) {
data.putAll(parse(filename));
// print the data to output.csv
print(data);
} catch (Exception e) {
e.printStackTrace();
private static Map<String,Set<String>> parse(String filename) throws IOException, ParseException {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(filename));
CsvLineParser.squeeze = true; // field.trim().replaceAll("\\s+"," ")
LineParser<String[]> parser = new CsvLineParser();
int lineNumber = 1;
// 1. read the column names (first line of file) into a List
// 2. read the column values (subsequent lines of file) into a List of Set's of String's
// 3. build a Map of columnName --> columnValues and return it
} finally {
if(reader!=null)reader.close();
private static void debugPrint(Map<String,Set<String>> data) {
for ( Map.Entry<String,Set<String>> entry : data.entrySet() ) {
System.out.println("DEBUG: "+entry.getKey()+" "+Arrays.toString(entry.getValue().toArray(new String[0])));
private static void print(Map<String,Set<String>> data) {
// 1. get the column names from the table.
// 2. create a List of List's of String's called matrix; logically [COL][ROW]
// 3. print the column names and add the List<String> for this col to the matrix
// 4. print the matrix by inerating columns and then rows
} -
Read csv file and insert the data to a list in sharePoint
Hi everyone,
i wrote a code that reads from a csv file all his data but i need also to insert all the data to a new list in sharePoint.
how can i do this?
plus, i need to read from the csv file once a day in specific hour. how can i do this? thank you so much!!Did you look at the example I posted above?
ClientContext in CSOM will allow you to get a handle on the SharePoint objects;
http://msdn.microsoft.com/en-us/library/office/ee539976(v=office.14).aspx
w: http://www.the-north.com/sharepoint | t: @JMcAllisterCH | YouTube: http://www.youtube.com/user/JamieMcAllisterMVP -
Loading external SWF fila and accessing variables/functions
Hello everybody!
My first post here. Actually I do search google for answers all the time, but now - it's tough one.
public function loadScreen(swf:File):void {
_content = swf;
var swfBytes:ByteArray = new ByteArray();
var file:File = _content;
var loadStream:FileStream = new FileStream();
loadStream.open( file, FileMode.READ );
loadStream.readBytes( swfBytes );
loadStream.close();
var loader:Loader = new Loader();
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
loaderContext.allowLoadBytesCodeExecution = true;
loader.loadBytes( swfBytes, loaderContext);
loader.contentLoaderInfo.addEventListener(Event.INIT, accessSWF);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
public function errorHandler(e:Event):void {
trace("PROBLEM LOADING BYTES");
public function accessSWF(e:Event):void {
var moduleLoader:LoaderInfo = LoaderInfo(e.target);
moduleLoader.content.addEventListener(Event.INIT, readyHandler);
public function readyHandler(e:Event):void {
_initOptions = new NativeWindowInitOptions();
with(_initOptions) {
resizable = true;
transparent = false;
var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
_window = new NativeWindow(_initOptions);
with(_window) {
activate();
bounds = boundsWin;
stage.scaleMode = "noScale";
The problem is that application loads the external swf with loadBytes, but it's not executing the script. Actually, I'm not able to use the loaded swf. I'm not able even to add it to Stage. But message in output still shows, that the swf file is loaded "[SWF] file.swf/[[DYNAMIC]]/1 - 2746 bytes after decompression"
There are many solutions for this problem on the internet, but they're old (written in 2008 most of all) and not working either, because those solutions work only in older AIR versions
Any help?Well I got a bit further:
public function loadScreen(swf:File):void {
var loadStream:FileStream = new FileStream();
with(loadStream) {
openAsync( swf, FileMode.READ );
addEventListener(ProgressEvent.PROGRESS, loadProgress);
addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
addEventListener(Event.COMPLETE, loadComplete);
public function loadProgress(e:ProgressEvent):void {
trace("Loading " + e.target.bytesAvailable);
public function errorHandler(e:IOErrorEvent):void {
trace("Error ");
public function loadComplete(e:Event):void {
var swfBytes:ByteArray = new ByteArray();
FileStream(e.target).readBytes( swfBytes );
var loaderContext:LoaderContext = new LoaderContext();
with(loaderContext) {
allowLoadBytesCodeExecution = true;
var loader:Loader = new Loader();
with(loader) {
loadBytes( swfBytes, loaderContext);
contentLoaderInfo.addEventListener(Event.INIT, completedSWF);
public function completedSWF(e:Event):void {
var moduleLoader:LoaderInfo = LoaderInfo(e.target);
moduleLoader.addEventListener(Event.COMPLETE, initiatedFinally);
public function initiatedFinally(e:Event):void {
_initOptions = new NativeWindowInitOptions();
with(_initOptions) {
resizable = true;
transparent = false;
var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
_window = new NativeWindow(_initOptions);
with(_window) {
activate();
bounds = boundsWin;
stage.scaleMode = "noScale";
var loader:Loader = e.target.loader;
loader.addEventListener(Event.ADDED_TO_STAGE, irAdded);
_window.stage.addChild(loader);
public function irAdded(e:Event):void {
trace(e.target.content.vars); // Object Dictionary
At this point ( function irAdded ) I'm able to retrieve external SWF's variables. But stil, it's not visible on the stage. And yet - there's another problem - rendering the same script , every second time application unloads the external swf movie. -
Reading a Blob (CSV file) and displaying the contents
Hello Experts,
I’m currently working on a system that allows the users to upload an Excel spreadsheet (.xls) in the system. The upload page is a PL/SQL cartridge. Then I’ve written a Java servlet (using Oracle Clean Content) to convert the XLS into a CSV and store it back in the database. (it is stored in the “uploaded_files” table as a blob). I’m trying to create another procedure to read the contents of the blob and display a preview of the data on the screen (using an html table (will be done using cartridge)). After the preview, the user can choose to submit the data into the database into the “detail_records” table or simply discard everything.
Can anyone provide me any guidelines and/or code samples for reading the contents of a blob and displaying it as an html table? My data contains about 10 rows and 20 columns in the spreadsheet. I’ve been looking into using associative arrays or nested tables but I’m getting confused about how to implement them in my situation.
Any help is greatly appreciated.BluShadow,
Thanks for your response. The reason that it is a blob is that we use the same table for uploaded files for several applications. Some files are text, some excel, some other formats. Hence the table has been set up in a generic sense.
However, in my procedure, I'm using
DBMS_LOB.createtemporary and
DBMS_LOB.converttoclob
Is there any way you could possibly provide an example of how to read the contents of the file? -
Can I load a LDIF file and initalise the database using iPlanet SDK?
I know how to create a new context in the DS, initialise its database with a LDIF file from the console or using the LDAPModify.
But would it be possible if I can create the context & initialise the database using the iPlanet SDK for Java?
I'm developing a module that would allow an user to create a new organisation, thereby the need to create the database using the SDK. How can I go about to achieve this?
Many thanks!I don't understand. If you know how to do everything using ldapmodify, it should be very straightforward to use java. What don't you understand?
-
Loading data into csv file based on the count of data in table in ODI
Hi,
I have a requirement like i have data in table and need to be loaded in csv file.
If the count of the data in the table exceeds the csv data limit then i need to call the same procedure again to
generate one more csv file and load the remaining data into it.my data in the table may vary all the time.
I am new to this ODI.Can anyone tell any ways to do it in ODI or tell me any logic to do this?
Thanks in advance..
Edited by: 883410 on May 22, 2012 12:01 AMWhat limit on the csv file are you talking about. There isn't a limit (unless you are on Unix where the filesize is limit is 2GB). Are you talking about opening it in earlier versions of Excel where the display limit is 60,000 rows as this is irrelevant for your operation?
-
Read a CSV file and dynamically generate the insert
I have a requirement where there are multiple csv's which needs to be exported to a sql table. So far, I am able to read the csv file and generate the insert statement dynamically for selected columns however, the insert statement when passed as a parameter
to the $cmd.CommandText
does not evaluate the values
How to evaluate the string in powershell
Import-Csv -Path $FileName.FullName | % {
# Insert statement.
$insert = "INSERT INTO $Tablename ($ReqColumns) Values ('"
$valCols='';
$DataCols='';
$lists = $ReqColumns.split(",");
foreach($l in $lists)
$valCols= $valCols + '$($_.'+$l+')'','''
#Generate the values statement
$DataCols=($DataCols+$valCols+')').replace(",')","");
$insertStr =@("INSERT INTO $Tablename ($ReqColumns) Values ('$($DataCols))")
#The above statement generate the following insert statement
#INSERT INTO TMP_APPLE_EXPORT (PRODUCT_ID,QTY_SOLD,QTY_AVAILABLE) Values (' $($_.PRODUCT_ID)','$($_.QTY_SOLD)','$($_.QTY_AVAILABLE)' )
$cmd.CommandText = $insertStr #does not evaluate the values
#If the same statement is passed as below then it execute successfully
#$cmd.CommandText = "INSERT INTO TMP_APL_EXPORT (PRODUCT_ID,QTY_SOLD,QTY_AVAILABLE) Values (' $($_.PRODUCT_ID)','$($_.QTY_SOLD)','$($_.QTY_AVAILABLE)' )"
#Execute Query
$cmd.ExecuteNonQuery() | Out-Null
jyeragiHi Jyeragi,
To convert the data to the SQL table format, please try this function out-sql:
out-sql Powershell function - export pipeline contents to a new SQL Server table
If I have any misunderstanding, please let me know.
If you have any feedback on our support, please click here.
Best Regards,
Anna
TechNet Community Support -
VBScript to read the content of a .csv file and delete old files mentioned in the .csv
I have a Windows 2003 file server.
I have generated a report in .csv format, about the files which are older than 1 year.
I need a VBScript to read the .csv file and delete the files which are enlisted there.
Can someone please help me with this?Look into the "Learn" link above. There are resources and instructions on how to write VBScript code. Look into how to use the FileSystemObject.
¯\_(ツ)_/¯ -
Hello,
I am very new to powershell and I have been looking for a solution where I can list all the inactive members more than 30 days from particular groups in AD, export the updated list to a csv file and send the file by email . . Can someone help me on
this?
thanksHi,
Take a look at Get-ADGroupMember, Get-ADUser, Export-Csv, and Send-MailMessage:
http://ss64.com/ps/get-adgroupmember.html
http://ss64.com/ps/get-aduser.html
http://ss64.com/ps/export-csv.html
http://ss64.com/ps/send-mailmessage.html
Let us know if you have any specific questions.
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing)
Maybe you are looking for
-
Sender File Adapter - FCC - No incoming field separator - How to do FCC?
Hi, I have a sender File adapter and I need to do the File Content Conversion but there apparently no incoming field separator and the file ocntains just running text - no data records but just information. For example the incoming file is something
-
Where can I find a "dummy" macbook pro
I work for a company who is looking to create some accessories for Macbook Pro 15" with retina display and 13" with retina display. I am looking to obtain either a "gutless" or "dummy" laptop to be able to send to Asia for sampling, etc. Or a broken
-
Wifi password incorrect on itouch but correct on laptop
what do i do when i know that i typed my password correctly but it says that its incorrect it works on my laptop perferctly!!!!!!!!!!!!!111 make update for itouch 2g
-
I am super worried!!!!! Help me!
-
Account Hacked! Refund process is a pain!!!
My account is hacked by someone to make calls to Ukraine. The automatic bill pay I set up ended up refill my account for $70. I had numerous (via chat) discussion with Skype customer support (been a week and at least 5 attempts) and the issue still n