Incrementing addresses in string format on Excel or Matlab?

I would like to go from this:

to this:

On either excel or matlab. This operation will have to be looped through an entire spreadsheet worth of addresses which is why I'm skeptical that excel has an efficient way of doing it. Please bear in mind the field "Address Number" is a string variable.

I have uploaded the spreadsheet as a Matlab Cell array and am thinking of extracting values one at a time,pre and post hyphen, converting to double and having the script increment and fill a new array but this is quite far fetched and I am not sure which are the relevant commands.

Thanks

Answers


To turn the address number into a series of numbers, the following code should help:

instring = '1428-32';
stub = instring;
digits = 0;
while ~strcmp(stub(end),'-')
    stub = stub(1:end-1);
    digits = digits + 1;
end
stub = stub(1:end-1); %stub is now your starting number, but as a string
maxval = instring(end-(digits-1):end);
maxval = strcat(stub(1:end-digits),maxval);
outlist = str2double(stub):str2double(maxval);

I'll leave it to you to figure out how to put this back into a larger array with the rest of the data in, it shouldn't be too difficult...


Need Your Help

Search filenames in MySQL database table restricted by filetype?

mysql search full-text-search replication sphinx

I have a MySQL database that I replicate from another server. The database contains a table with this columns

Adding records to WooCommerce tables via MySQL stored procedure

mysql wordpress

This is more of a MySQL query question, but those with experience working with WooCommerce might have some valuable insight.