Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %returns the quicksale and slowsale value of a material based on a parse of
- %market dump
- %Input: Material (using space not underscore for something like Dark
- %Ochre), Region (eg Heimatar), station (numerical ID), filelocation, eg
- %C:\Users\Alex\Documents\EVE\logs\Marketlogs\
- %
- %Output: [Quicksale,Slowsale]
- %
- %Example
- %[Veldspar_quicksale,Veldspar_slowsale]=marketparse('Veldspar', 'Heimatar',
- %60004588, 'C:\Users\Alex\Documents\EVE\logs\Marketlogs\')
- function[quicksale,slowsale] = marketparse(material, region, station, filelocation)
- %material='Veldspar';
- %region='Heimatar';
- %station=60004588;
- %filelocation='C:\Users\Alex\Documents\EVE\logs\Marketlogs\';
- filelist=struct2cell(dir(strcat(filelocation,region,'-',material,'*')));
- filelist_size=size(filelist);
- timestamp_values=zeros(filelist_size(2));
- for (counter=1:filelist_size(2))
- timestamp_values(counter)=filelist{5,counter};
- end
- timestamp=max(timestamp_values(:,:));
- current_timestamp=filelist{5,1};
- while (current_timestamp ~= timestamp)
- filelist_size=size(filelist);
- filelistb={filelist{1,2:filelist_size(2)};filelist{2,2:filelist_size(2)};filelist{3,2:filelist_size(2)};filelist{4,2:filelist_size(2)};filelist{5,2:filelist_size(2)}};
- filelist=filelistb;
- clear filelistb
- current_timestamp=filelist{5,1};
- end
- filelist=strcat(filelocation,char(filelist{1,1}));
- fid=fopen(filelist);
- trash=fgetl(fid);
- market=textscan(fid,'%f,%f,%f,%f,%f,%f,%f,%s %f:%f:%f,%f,%f,%f,%f,%f,%s');
- market_price=market{1,1};
- market_string=market{1,8};
- market_station=market{1,13};
- counter=1;
- while (counter<max(size(market_price)))
- if (market_station(counter) ~= station)
- if (counter==1)
- market_price=market_price(2:max(size(market_price)));
- market_string={market_string{2:max(size(market_string))}}';
- market_station=market_station(2:max(size(market_station)));
- else
- if (counter==max(size(market_price)))
- market_price=market_price(1:counter-1);
- market_string={market_string{1:counter-1}}';
- market_station=market_station(1:counter-1);
- else
- market_price=[market_price(1:counter-1);market_price(counter+1:max(size(market_price)))];
- market_string={market_string{1:counter-1},market_string{counter+1:max(size(market_string))}}';
- market_station=[market_station(1:counter-1);market_station(counter+1:max(size(market_station)))];
- end
- end
- else
- counter=counter+1;
- end
- end
- number_of_values=max(size(market_price));
- counter=0;
- sellers=0;
- while (counter<number_of_values)
- counter=counter+1;
- test_value=(market_string{counter}=='F');
- if (test_value(1)==1)
- sellers=sellers+1;
- end
- end
- counter=0;
- buyers=0;
- while (counter<number_of_values)
- counter=counter+1;
- test_value=(market_string{counter}=='T');
- if (test_value(1)==1)
- buyers=buyers+1;
- end
- end
- counter=0;
- counter2=1;
- if (sellers==0)
- slowsale=0;
- else
- slowsale_vector=zeros(1,sellers);
- while (counter<number_of_values)
- counter=counter+1;
- test_value=market_string{counter}=='F';
- if (test_value(1)==1)
- slowsale_vector(counter2)=market_price(counter);
- counter2=counter2+1;
- end
- end
- slowsale=min(slowsale_vector);
- end
- counter=0;
- counter2=1;
- if (buyers==0)
- quicksale=0;
- else
- quicksale_vector=zeros(1,sellers);
- while (counter<number_of_values)
- counter=counter+1;
- test_value=market_string{counter}=='T';
- if (test_value(1)==1)
- quicksale_vector(counter2)=market_price(counter);
- counter2=counter2+1;
- end
- end
- quicksale=max(quicksale_vector);
- end
Add Comment
Please, Sign In to add comment