For each loop with multidimensional arrays?
Hi.I have a problem with for each and multidimensional combination.
public class TestCards
static int[][] dizi={{1,2},{3,4}};
static int t ;
public static void main(String[]args)
for (int[] i : dizi)
System.out.println(i);
The result of the codes above is like this
[I@9304b1
[I@190d11
In other words the result is now integer.It has some strange chars which i dont know
Pls help me !
You're printing an array. Arrays don't override toString.
- You could iterate over both dimensions and print each value yourself.
- You could iterate over one dimension and call java.util.Arrays.toString to print a row at a time.*
- You could call java.util.Arrays.deepToString to print the entire thing in one shot.
*The second option is closest to what you're doing now.
Similar Messages
-
For-each loop with colon in group name
When making my first simple RTF report with XML Publisher, I am encountering problems with an XML tag name that contains a colon. When I set the tag name as the group for a loop - <?for-each:Blah1:Blah2?>, where Blah1:Blah2 is the tag name in my XML file, I get an error - java.lang.reflect.InvocationTargetException ... caused by oracle.xdo.parser.v2.XPathException: Namespace prefix 'Blah1' used but not declared. Any help would be appreciated.
JWHi JW
The colon denotes that you XML is using a namespace and you need to declare in in your template. Just check out the user guide for namespaces. Its pretty straigntforward. I also touched on it in the latest blog entry here, http://blogs.oracle.com/xmlpublisher
Regards
Tim -
For Each Loop Load Dynamic Excel Files
Hi All,
SSIS 2005
I want to load excel file .xls one at a time files that have different names without having to select the file in the connection manager, every time. So a user can easily place the excel file in the folder and right the sql job and it loads the file data.
The data flow tasks all work when I manually select the excel file, but I am unable to get this to work dynamically.
I have setup a for each loop with multiples data flow tasks and sql tasks to load my data from file.
Variables:
@filename d:\new file\*.xls
For Each Loop:
ForEachFile Enumerator
Folder: d:\new file\
Files: *.xls
Retrieve File Name: Fully Qualified
Variable Mappings:
User::filename (index 0)
Connection Managers:
Excel Connection Manager: Expressions, ConnectionString @[User::filename]
Error Message: Error at new buyer(package name) the connection string format is not valid. it must consist of one or more components of the form X=Y, seperated by semicolons.
Can anyone assist thanks.You still need the file name variable.
ExcelFilePath is the fully qualified file name of your Excel file. ie. it contains both the path and file name.
e.g. D:\inbox\myExcelFile.xls
All the steps you mentioned are correct, except you need to set the property of ExcelFilePath of the Excel connection to the variable that you map to in the ForEach Loop:
Connection Managers:
Excel Connection Manager: Expressions, ExcelFilePath @[User::filename]
Hope this helps.
~ J. -
Using IF in a for each loop which is grouped by two fields
Hi ,
My requirement is to filter the Payment records ,based on the parameter input date and also group by based on two of the Fields and calculate the sum of the payment Amounts.
I have created a for each loop with the group by first on one field and then the other field.
My question is where should I put my IF condition based on parameter dates ?
If condition would be if Created = Date Parameter .CAn anybody help where I should insert the IF condition in the below code.
Ex:
<?for-each-group:Payments;./Created?>
Display Date : Created
<?for-each-group:current-group();./CreatedByName?>
Table : CreatedByName count of Payments Sum of Amount
<?end for-each-group?>
<?end for-each-group?>
thanks.Hi ,
I got the result by putting the filter in [ ]
Ex:
<?for-each-group:Payments[PaymentStatus != 'New';./CreatedDate?>
here I am filtering the records based on [Payment Status != New] and then group by Created Date .
Similarly I can new another condition as well in the same statement
<?for-each-group:Payments[PaymentStatus != 'New'][PaymentMethod != 'Cash'];./CreatedDate?>
Regards. -
Custom List with for-each loop
How do I get a list I am making to be able to be used with a for-each loop?
As far as I know there is no "for-each" loop in Java, there is however a "for" loop. Is that what you're referring to?
To use a for loop, let's say you have an array like the following, you could iterate through it like this:
String[] str = new String[]{"a", "b", "c", "d", "e"};
for (int i = 0; i < str.length; i++)
System.out.println(str);
hope this help you get started ;-) -
For each loop to print a 3D array
I want to display the elements of my 3d uniform array but after each element I get a "null" also. Any idea why? I've tested with a 2d array and I don't have any problem. Any help is really appreciated.
public class Testari {
public static void main(String[] args) {
String[][][] my3DArray = new String[3][2][2];
my3DArray[0][0][0] = "a"; //3d uniform array
my3DArray[0][1][0] = "b";
my3DArray[1][0][0] = "c";
my3DArray[1][1][0] = "d";
my3DArray[2][0][0] = "e";
my3DArray[2][1][0] = "f";
for(String[][] x : my3DArray) {//for each loop
for(String[] y : x){
for(String z : y){
System.out.println(z + " ");
}What's 3 x 2 x 2?
How many elements did you explicitly set?
How many elements does that leave with their default value of null? -
SQL Agent Permssions With SSIS for each loop not looping through files
Hi I am Having trouble getting a ssis package to iterate through a file directory using a proxy account set up in Sql Server.
So I have a package that loops over csv files. If I run the package manually or set the sql agent job to run as Sysadmin the pakage runs fine all files are processed.
However if I use the proxy account. the package completes but no files are processed. there are no failures, there is no error handling set up in the control flow. the for each loop container simply does not recognise any files when run under a proxy.
Note: the proxy is set up with credentials to access the folder. the credential is also set up with the server admin server role... still nothing
i'm not sure is this is a ssis or permissions problem?
Any comments will be appreciatedCan you check this and see if you've configured all the steps correctly
http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Also enable logging in package and see if you're getting any error messages obtained in output table/file based on the logging option you chose.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to use for each loop in XSLT when my source is a multilayout file and db
How do I use a for each loop in XSLT when my source is multilayout file and db .
My multilayout file is basically contain 2 kind of data one for employee and another for dependent.
Now my requirement is I want to read each line of data whether it is it is employee or dependent do a join with db and write it in my target file.
eg : File content
1 RichaKumari 311289 TCS INDIA
2 KiarnKumar 456782 BRO RichaKumari 311289 INDIA
2 Ravi 456882 BRO RichaKumari 311289 INDIA
eg : db Content
311289 RichaKumari TCS INDIA Bangalore [email protected]
Now in Final File I need something like this :
1 RichaKumari 311289 TCS INDIA
2 KiarnKumar RichaKumari 311289 TCS INDIA
2 Ravi RichaKumari 311289 TCS INDIA
here 1 and 2 are the identifier which will decide which layout to follow .Hi,
I think you'll need two nested for-each's... Something like...
<xsl:for-each select="$root/row[layout = 1]">
<xsl:variable name="employee" select="."/>
... write employee ...
<xsl:for-each select="$root/row[layout = 2 and dependentid = $employee/id]">
... write dependent ...
</xsl:for-each>
</xsl:for-each>
Cheers,
Vlad -
Loading accdb file using for each loop in to single target table
I have 3 accdb file as below in single folder, in control flow I have created a for each loop to loop through all the below file. In dataflow task I have created oledb source using connection manager to point to first file a1.accdb. I am trying
to load all the file into single below mentioned target table, here It is only loading first file it is not looping through other two file.
This I have tried to load .txt files and csv files it is working perfectly but similarly when I try to load access db file table it is not working, can any one of you help me?
1. a1.accdb contains only one table a1tab ( col1 col2 col3 )
2. a2.accdb contains only one table a2tab ( col1 col2 col3 )
3. a3.accdb contains only one table a3tab ( col1 col2 col3 )
I have a target table with similar structure as source
Target table <TargetTable> Col1 Col2 Col3
aakThanks Arthur, please find below response
How do you handle the different table names? Cant we handle it in a similar manner, how we handle the .csv/.txt files with different name and similar structure for sources(multiple files) and target (single table)
Is it good to drop the idea of for each loop and create a separate task for each accdb file? to be loaded to same target table( performance wise etc.. any justification would be helpful)
You must handle the connection string dynamically?
Can you help me with the logic for handling connection string dynamically
aak -
How can I enable for-each loop in Creator update 1?
I try to use for-each loop, but I got error message from compiler is
" for-each loops are not supported in -source 1.4. (try -source 1.5 to enable for-each loops)"
How can I switch my source to 1.5.. I am using jdk 1.5. Confusing.
Thanks .
RichardHi!
Actually Sun Java Studio Creator doesn't support Java EE 5 projects. If You want to create Java EE 5 project, try to use NetBeans with Visual Web Pack installed.
Thanks,
Roman. -
For Each Loop in Jdev 10.1.2.17.84
Is there anyway of using a for each loop in Jdev 10.1.2.17.84? I get errors for the standard syntax:
for (int item : numbers) {
System.out.println("Count is: " + item); }
Am i missing something?Okay, i'm on 10.1.3 now and the syntax:
for (int item : numbers) {
System.out.println("Count is: " + item); }
still doesn't work. What am I missing now?
On compile I'm getting:
Error(41,23): ; expected
for the line with for (int item : numbers) { -
Hello Everyone,
Please assist with a step by step guide on how to setup a For Each Loop for XML Task
I'm trying to convert XML to XSLT
I have tried more than 10 times and i just do not know what i am doing wrong - no error, my package just runs for a few seconds but nothing happens
Thanks in advance
DeeI managed to get my XML to XSLT to work but now when i run my package to import the data into SQL table,
it stops after a few records, i get the following error:
[XML Source [1]] Error: The component "XML Source" (1) was unable to process the XML data. The element "Errors" cannot contain a child element. Content model is text only.
Please assist
Check this:
http://social.msdn.microsoft.com/Forums/en-US/80726e0c-9e85-43ca-87bc-7cf90fd7fb31/xml-source-data-flow-throws-cannot-contain-a-child-element-content-model-is-text-only-error?forum=sqlintegrationservices
Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
The climb is all there is. -
For Each loop that iterates in reverse order
Can I use the For Each loop to iterate in reverse order?
Like this:
int[] array=new int[10];
for(int i=array.length-1;i<=0;i--)
int j=array; -
For each loop and modification of a LinkedList
When going thourhg my LinkedList with a for each loop, I want to do a modification. I just saw that it cast a ConcurrentModification Exception, so it seems I can't do that.
How should I do then? I don't want to go through all the list each time an object is removed, I want it to restart where it stopped.Not the best solution but something like thisshould work:
if( linkedList.get(i) == "modification")No: don't compare Strings with the == operator.
http://access1.sun.com/FAQSets/newtojavatechfaq.html#9
You are correct, must be .equals() my bad. -
For Each Loop: Enumerator Configuration In the For each loop Editor Help needed
Hi All,
I have a package that runs and updates a table with everytime someone adds a flat file in the source folder. One of the requirement is to upload files with the following
ACA Flat files will have a naming convention of “ACA_ccyy_<julian date>” : How can I add this?
Under Files this is how I have setup the qualifies "ACA_*.*"
Is there anyway to pass the entire naming convention in the file section? If so how can I ?
Please help?
FMAs you have ACA_*.* set in Files Filter, it will return all the files from the folder which start with ACA_.
You can have one dummy Sequence Container inside FE Loop Container. Connect it to your starting task and do right click on Precedence Constraint and write the expression the way you want by using SSIS functions. If the expression is evaluated to True only
then it will go to the next task.
In this way you can skip Non-ACA files.
Please refer:
SSIS Skip Certain Files in a For Each Loop
- Vaibhav
Maybe you are looking for
-
How do I upgrade my Core2Duo Mini OSX10.4.11 to the latest version of Snow Leopard? I am aware I should upgrade from 1GB to 2GB of RAM. Can I just purchase the Snow Leopard DVD and install from that? Will I be able to run my Microsoft Office 2004 s
-
If i connect an external hard drive to a time capsule, can i access this drive via internet?
-
IRVLJWTA: Exceeded configured maximum number of allowed ...
Hi all, when creating a pivot table and setting a colom into the section, i'm getting the IRVLJWTA: Exceeded configured maximum number of allowed output prompts, sections, rows, or columns. Can anyone give me an hint where to configure this setting?
-
Login manager neeeded for PAM to work properly?
I just caught a comment on an AUR kernel package that warned that a login manager must be used in order for PAM to function. Can some on verify this? Is there a way to verify PAM is running properly? To clarify: I do not need a login manager and have
-
Shared Excel Files Problem in Leopard
I have a large number of files I want to share with another user under leopard on one computer so we can each read and write them. I have tried to use the "shared" folder feature under "users." However, Excel seems to have a problem with this even