Jump to content

How to delete rows in array


nbala75
 Share

Recommended Posts

Iam scratching my head to write something like...

I get a csv file with first col like this. Both these figures are present in the first col itself. The first being time and the second one is a number.

14:17:56 4407.85

14:16:56 4399.05

14:15:58 4395.90

14:14:56 4396.15

14:13:58 4392.20

14:12:58 4400.70

14:33:58 4433.20

14:32:58 4427.50

14:31:56 4427.35

14:30:58 4425.20

14:29:56 4425.60

14:28:59 4426.75

14:27:57 4428.00

If the minute field of the above excel row equals/exceeds every fifteenth minute then those needs to be deleted from the array (not from excel). I may get multiple rows for each minute with diff timestamps.

Say

Delete if min field equals 15 or 16 or 17 till i get 29th min rows.

Once 29th minute fields are there, then delete rows containing minute field equals/exceeds 30 31 etc from the array

once 44th minute fields are there, then delete rows containing minute field equals/exceeds 45 46 etc from the array

once 59th minute fields are there, then delete rows containing minute field equals/exceeds 00 01 etc from the array

Thanx for the good souls

Edited by nbala75
Link to comment
Share on other sites

Check out the arraydelete() function:

#include <Array.au3>

Local $avArray[10]

$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"

_ArrayDisplay($avArray, "$avArray BEFORE _ArrayDelete()")
_ArrayDelete($avArray, 8)
_ArrayDisplay($avArray, "$avArray AFTER _ArrayDelete()")
Link to comment
Share on other sites

Check out the arraydelete() function:

#include <Array.au3>

Local $avArray[10]

$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"

_ArrayDisplay($avArray, "$avArray BEFORE _ArrayDelete()")
_ArrayDelete($avArray, 8)
_ArrayDisplay($avArray, "$avArray AFTER _ArrayDelete()")

Yeah..thanx

At first it looked complex...needing to use loops etc...but when u wrote the above msg, i had a look again and alas! it was just simple....at times, mind needs some rest to look at things in proper perspective...i just cudnt get this easily earlier...sorry guys

Link to comment
Share on other sites

  • 3 years later...

Read the help file for _ArrayDelete, the latest version adds the ability to delete a range of rows or just a single one.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

A general piece of advice: When deleting rows (or sets of rows) several times, it's normally easier to start at the end of the array and work your way to the beginning. This avoids having to adjust index numbers to compensate for rows which have already been deleted.

Edited by czardas
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...