473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Extract data from arrays

Hi

This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.

I have an array with a large number of elements in it. 0-9 are related
data, 10-19, 20-29 are related and so on. What is the best way of extracting
groups of elements from the array into another array where each element is
the related data or to extract say elements 0,1,5 from the first group,
10,11,15 from the second etc.

I have tried iterating through the array with if then statements but for a
large array this gets messy.

Any advice would be greatly appreciated.

Regards
Ian


Feb 8 '08 #1
5 2822
If the elements are always 10, or some such number, that are related,
why not use a multi dimensional array instead?

T

ilr wrote:
Hi

This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.

I have an array with a large number of elements in it. 0-9 are related
data, 10-19, 20-29 are related and so on. What is the best way of extracting
groups of elements from the array into another array where each element is
the related data or to extract say elements 0,1,5 from the first group,
10,11,15 from the second etc.

I have tried iterating through the array with if then statements but for a
large array this gets messy.

Any advice would be greatly appreciated.

Regards
Ian

Feb 8 '08 #2
Thanks for replying tomb.

The array is returned from a 3rd pary library so I don't really have much
choice in that respect.

"tomb" wrote:
If the elements are always 10, or some such number, that are related,
why not use a multi dimensional array instead?

T

ilr wrote:
Hi

This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.

I have an array with a large number of elements in it. 0-9 are related
data, 10-19, 20-29 are related and so on. What is the best way of extracting
groups of elements from the array into another array where each element is
the related data or to extract say elements 0,1,5 from the first group,
10,11,15 from the second etc.

I have tried iterating through the array with if then statements but for a
large array this gets messy.

Any advice would be greatly appreciated.

Regards
Ian


Feb 8 '08 #3
Hi Lan

Sounds like this is an Algorithm question :)

I'm still not very sure about the exact result you want.

My understanding is you have a source array which may contains a large
sequence of elements. And a certain sub sequence of elements in the array
are of the same group(according to their index in array or their value?)
and you want to extract them out from the array and make the elements of
the same group together, correct?

As Tomb mentioned the "two-dim" array approach, I also think this is a good
idea if the interval or size of each group are fixed. You can create a
two-dimensional array in your code and copy all the elements from original
array into the two dimensional array.

Also, I think it would be helpful you provide more info such as some
example data(what's the original array and what you want to make them be
tranformed into and how you will use them after transformed). Thus, we can
look for some further ideas on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
\\
>From: =?Utf-8?B?aWxy?= <il*@noemail.noemail>
References: <F7**********************************@microsoft.co m>
<_T*******************@bignews7.bellsouth.net>
>Subject: Re: Extract data from arrays
Date: Thu, 7 Feb 2008 20:39:00 -0800
\
>
Thanks for replying tomb.

The array is returned from a 3rd pary library so I don't really have much
choice in that respect.

"tomb" wrote:
>If the elements are always 10, or some such number, that are related,
why not use a multi dimensional array instead?

T

ilr wrote:
Hi

This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.

I have an array with a large number of elements in it. 0-9 are
related
data, 10-19, 20-29 are related and so on. What is the best way of
extracting
groups of elements from the array into another array where each
element is
the related data or to extract say elements 0,1,5 from the first
group,
10,11,15 from the second etc.

I have tried iterating through the array with if then statements but
for a
large array this gets messy.

Any advice would be greatly appreciated.

Regards
Ian

Feb 8 '08 #4
ilr,

This is so easy in VB

\\\
For i = X To 99 Step 10
'What you want to do
Next
///

Cor
Feb 9 '08 #5
Thanks Cor

I had considered step. Count gives me each 10th value. I was looking to
group the 10 values together.

Regards
ilr

"Cor Ligthert[MVP]" wrote:
ilr,

This is so easy in VB

\\\
For i = X To 99 Step 10
'What you want to do
Next
///

Cor
Feb 14 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tim Smith | last post by:
I am looking to extract form element values from html, more generally I have a substring that identifies the beginning of a value and a string that identifies the end of value and I need to extract...
2
by: zlf | last post by:
Hi, This there any existing alorgithm in .NET that can extract the common element in two string arrays to another string array; usage: string a = { "1","2","3" }; string b = { "1" }; string...
0
by: Brian Hanson | last post by:
Hi, I have an unusual problem that just showed its ugly head at a pretty bad time. I have an asp.net (VB) app that takes data from an Excel sheet and puts it into SQL Server. I get the data...
2
by: | last post by:
While I can extract the option value from the following: <Select name='Keystring' MULTIPLE> <option value='1' name='status'>Pending</option> ..... </select> I cannot seem to extract the...
8
by: Fabian Braennstroem | last post by:
Hi, I would like to remove certain lines from a log files. I had some sed/awk scripts for this, but now, I want to use python with its re module for this task. Actually, I have two different...
0
by: napolpie | last post by:
DISCUSSION IN USER nappie writes: Hello, I'm Peter and I'm new in python codying and I'm using parsying to extract data from one meteo Arpege file. This file is long file and it's composed by...
2
by: kimi | last post by:
Hi ppl, I am new to PHP. I would need some information on the following: 1. a) I wanted to know from where the data is extracted and stroed in the global assocoative arrays ( specifically...
20
by: kosanovic | last post by:
Hello, I'm bad at regular expressions. Would somebody help me: I need to extract all URL to .jpg and .png pictures from a string containing an HTML file (DOM wouldn't work well in what I need). ...
1
by: rcamarda | last post by:
I'd need to have a function that allows me to extract 'fields' from within the string I.E. (kinda pseudo code) declare @foo as varchar(100) set @foo = "Robert*Camarda*123 Main Street" select...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.