I want to search through <dynamic> List in dart - flutter
I have a list of products, the list is below:
List<dynamic>products = [
{
"id": 3,
"name": "Apple MacBook Air 13.3-Inch 10th Gen Core i3-1.1GHz, 8GB RAM, 256GB SSD (MWTJ2) Space Gray 2020",
"price": 126000,
"descriptions": "Processor\tIntel Core i3-1000NG4 Processor (4M Cache, 1.10 GHz up to 3.20 GHz)\r\n\r\nMemory\t 8GB 3733MHz LPDDR4X onboard RAM\r\n\r\nStorage\t 256GB SSD\r\nGraphics\tIntel Iris Plus Graphics; **Support for Thunderbolt 3–enabled external graphics processors (eGPUs)\r\n\r\nDisplay\t 13.3-inch (diagonal) Retina LED-backlit display with IPS technology; 2560-by-1600 native resolution at 227 pixels per inch with support for millions of colors\r\n\r\nAdapter\t 30W USB-C Power Adapter; USB-C power port\r\n\r\nBattery\tUp to 10 hours battery back (Video & web browsing up to 05 hours depending on resolution) Built-in 49.9 watt-hours lithium-polymer battery\r\n\r\nOperating System\tmacOS\r\n\r\nNetworking\t 802.11ac Wi-Fi wireless networking; IEEE 802.11a/b/g/n compatible\r\n\r\nTouchpad\t Multi-Touch gestures\r\n\r\nKeyboard\tBacklit Keyboard - US English Retina is equipped with: 78 keys (ANSI specification) or 79 keys (ISO specification), including 12 function keys and 4 direction keys arranged in an \"inverted T\" shape. Ambient light sensor Force touchpad brings precise cursors Control and pressure-sensing functions, support forceful long-press, acceleration function, pressure-sensitive drawing, and multi-touch gestures\r\n\r\nBluetooth\tBluetooth 5.0 wireless technology\r\n\r\nAudio\t Stereo speakers; Wide stereo sound; Support for Dolby Atmos playback; Three-mic array with directional beamforming; 3.5 mm headphone jack\r\n\r\nOptical Drive None\r\n\r\nSoftware\tFinal Cut Pro X; Logic Pro X\r\n\r\nWebCam\t720p FaceTime HD camera\r\n\r\nFingerprint\tYes\r\n\r\nDisplay Touch\tDisplay WithTouch ID sensor\r\n\r\nPorts & Connectors\t2 x Thunderbolt 3 (Supports DisplayPort and Power Delivery); Thunderbolt (up to 40Gb / s); USB 3.1 Gen 2 (up to 10Gb / s; 1 x HDMI; 1 x VGA; 1 x 3.5 mm Headphone Output\r\n\r\nColor\tSpace Gray\r\n\r\nDimensions (W x D x H)\tThickness: 0.41 to 1.61 cm (0.16 to 0.63 inches); Width: 30.41 cm (11.97 inches); Depth: 21.24 cm (8.36 inches)\r\n\r\nWeight\t1.29 kg (2.8 lbs)\r\n\r\nIncluded in the Box\tMacBook Air; 30W USB-C Power Adapter; USB-C Charge Cable (2 m)\r\n\r\nWarranty \t01 year International Limited Warranty (Terms & Condition Apply As Per Apple)",
"image": "/images/macbook_IU3NvNF.jpg",
"created_at": "2022-08-19T17:42:13.118095Z",
"updated_at": "2022-08-19T17:42:13.118095Z",
"stock": true,
"category": 1,
"user": "mosta"
},
{
"id": 2,
"name": "MSI Modern 14 B10MW Core i3 10th Gen 14\" Full HD Laptop",
"price": 50890,
"descriptions": "Processor Intel Core i3 10110U Processor (4MB Cache, 2.1Ghz up to 4.1Ghz)\r\n\r\nDisplay 14.0\" FHD (1920x1080), IPS-Level Display\r\n\r\nMemory 4GB 2666MHz DDR4 RAM, (Suppoorted Up to 16GB)\r\n\r\nStorage 256GB NVMe SSD (Supported Up to 1TB)\r\n\r\nGraphics Intel UHD Graphics\r\n\r\nOperating System Free Dos\r\nBattery 39.3Whr\r\n\r\nAdapter 65W adapter\r\n\r\nInput Devices\r\nKeyboard Backlight Keyboard\r\n\r\nWebCam HD type (30fps#720p)\r\nCard Reader 1x Micro SD\r\n\r\nNetwork & Wireless Connectivity\r\nWi-Fi 802.11 ac Wi-Fi\r\n\r\nBluetooth Bluetooth v5\r\n\r\nPorts, Connectors & Slots\r\nUSB (s) 2x Type-A USB2.0\r\n\r\n1x Type-C USB3.2 Gen2\r\n\r\nHDMI 1x (4K # 30Hz) HDMI\r\n\r\nAudio Jack Combo 1x Mic-in/Headphone-out Combo Jack\r\n\r\nExtra RAM Slot NO\r\n\r\nExtra M.2 Slot NO\r\n\r\nPhysical Specification\r\nDimensions (W x D x H) 319 x 220.2 x 16.9 mm\r\n\r\nWeight 1.3 kg\r\n\r\nColor(s) Carbon Gray\r\n\r\nWarranty\r\nManufacturing Warranty 02 Year",
"image": "/images/msi_sCwzOcI.jpeg",
"created_at": "2022-08-19T17:41:53.358014Z",
"updated_at": "2022-08-19T17:41:53.358014Z",
"stock": true,
"category": 1,
"user": "mosta"
},
{
"id": 1,
"name": "iPhone 13 Pro Max",
"price": 169000,
"descriptions": "First Release\tSeptember 24, 2021\r\n\r\nColors\tGraphite, Gold, Silver, Sierra Blue\r\n\r\nNetwork\t2G, 3G, 4G, 5G\r\n\r\nSIM\tNano / Electronic SIM\r\n\r\nWLAN\t✅ dual-band, Wi-Fi hotspot\r\n\r\nBluetooth\t✅ v5.0, A2DP, LE\r\n\r\nGPS\t✅ A-GPS, GLONASS, GALILEO, BDS, QZSS\r\n\r\nRadio\t✖\r\n\r\nUSB\tLightning, USB 2.0\r\n\r\nOTG\t✅\r\n\r\nUSB Type-C\t✖ (Proprietary reversible connector)\r\n\r\nNFC\t✅\r\n\r\nStyle\tNotch\r\n\r\nMaterial\t Gorilla Glass front & back, stainless steel frame\r\n\r\nWater Resistance\t✅ IP68 dust/water resistant (up to 6m for 30 mins)\r\n\r\nDimensions\t160.8 x 78.1 x 7.7 mmillimeters\r\n\r\nWeight\t240 grams\r\n\r\nSize\t6.7 inches\r\n\r\nResolution\t1284 x 2778 pixels (458 ppi)\r\n\r\nTechnology\tSuper Retina XDR OLED Touchscreen\r\n\r\nProtection\t✅ Scratch-resistant ceramic glass, oleophobic coating\r\n\r\nFeatures\tDolby Vision, HDR10, 1200 nits (max.), 120Hz, true-tone, wide color gamut\r\n\r\nResolution\tQuad 12+12+12 Megapixel + TOF 3D LiDAR scanner\r\n\r\nFeatures\tDual Pixel PDAF, sensor-shift OIS, dual-LED flash, ultrawide, depth, telephoto, 3x optical zoom & more\r\n\r\nVideo Recording\t4K (2160p), Dolby Vision HDR, ProRes, Cinematic mode, stereo sound rec.\r\n\r\nResolution\tDual 12 Megapixel + SL 3D\r\n\r\nFeatures\tF/2.2, HDR, 1/3.6″, depth / biometrics sensor\r\n\r\nVideo Recording\t4K (2160p), gyro-EIS\r\n\r\nType and Capacity\tLithium-ion 4352 mAh (non-removable)\r\n\r\nFast Charging\t✅ 27W Fast Charging (50% in 30 minutes)\r\n\r\nUSB Power Delivery 2.0\r\n\r\nWireless Charging\t✅ Fast Wireless Charging (15W MagSafe, 7.5W Qi magnetic)\r\n\r\nOperating System\tiOS 15\r\n\r\nChipset\tApple A15 Bionic (5 nm)\r\n\r\nRAM\t6 GB\r\n\r\nProcessor\tHexa-core, up to 3.22 GHz\r\n\r\nGPU\tApple GPU (5-core graphics)",
"image": "/images/iPhone13promax_YiZ3ktK.jpg",
"created_at": "2022-08-19T17:41:27.837767Z",
"updated_at": "2022-08-19T17:41:27.837767Z",
"stock": true,
"category": 2,
"user": "mosta"
}
]
I want to search through the above list by product name. And also want a make separate list contain one single map.
If i search "apple" the result should be:
List<dynamic> searchResult = [
{
"id": 3,
"name": "Apple MacBook Air 13.3-Inch 10th Gen Core i3-1.1GHz, 8GB RAM, 256GB SSD (MWTJ2) Space Gray 2020",
"price": 126000,
"descriptions": "Processor\tIntel Core i3-1000NG4 Processor (4M Cache, 1.10 GHz up to 3.20 GHz)\r\n\r\nMemory\t 8GB 3733MHz LPDDR4X onboard RAM\r\n\r\nStorage\t 256GB SSD\r\nGraphics\tIntel Iris Plus Graphics; **Support for Thunderbolt 3–enabled external graphics processors (eGPUs)\r\n\r\nDisplay\t 13.3-inch (diagonal) Retina LED-backlit display with IPS technology; 2560-by-1600 native resolution at 227 pixels per inch with support for millions of colors\r\n\r\nAdapter\t 30W USB-C Power Adapter; USB-C power port\r\n\r\nBattery\tUp to 10 hours battery back (Video & web browsing up to 05 hours depending on resolution) Built-in 49.9 watt-hours lithium-polymer battery\r\n\r\nOperating System\tmacOS\r\n\r\nNetworking\t 802.11ac Wi-Fi wireless networking; IEEE 802.11a/b/g/n compatible\r\n\r\nTouchpad\t Multi-Touch gestures\r\n\r\nKeyboard\tBacklit Keyboard - US English Retina is equipped with: 78 keys (ANSI specification) or 79 keys (ISO specification), including 12 function keys and 4 direction keys arranged in an \"inverted T\" shape. Ambient light sensor Force touchpad brings precise cursors Control and pressure-sensing functions, support forceful long-press, acceleration function, pressure-sensitive drawing, and multi-touch gestures\r\n\r\nBluetooth\tBluetooth 5.0 wireless technology\r\n\r\nAudio\t Stereo speakers; Wide stereo sound; Support for Dolby Atmos playback; Three-mic array with directional beamforming; 3.5 mm headphone jack\r\n\r\nOptical Drive None\r\n\r\nSoftware\tFinal Cut Pro X; Logic Pro X\r\n\r\nWebCam\t720p FaceTime HD camera\r\n\r\nFingerprint\tYes\r\n\r\nDisplay Touch\tDisplay WithTouch ID sensor\r\n\r\nPorts & Connectors\t2 x Thunderbolt 3 (Supports DisplayPort and Power Delivery); Thunderbolt (up to 40Gb / s); USB 3.1 Gen 2 (up to 10Gb / s; 1 x HDMI; 1 x VGA; 1 x 3.5 mm Headphone Output\r\n\r\nColor\tSpace Gray\r\n\r\nDimensions (W x D x H)\tThickness: 0.41 to 1.61 cm (0.16 to 0.63 inches); Width: 30.41 cm (11.97 inches); Depth: 21.24 cm (8.36 inches)\r\n\r\nWeight\t1.29 kg (2.8 lbs)\r\n\r\nIncluded in the Box\tMacBook Air; 30W USB-C Power Adapter; USB-C Charge Cable (2 m)\r\n\r\nWarranty \t01 year International Limited Warranty (Terms & Condition Apply As Per Apple)",
"image": "/images/macbook_IU3NvNF.jpg",
"created_at": "2022-08-19T17:42:13.118095Z",
"updated_at": "2022-08-19T17:42:13.118095Z",
"stock": true,
"category": 1,
"user": "mosta"
}]
How to approach to make this step?
import 'package:collection/collection.dart';
and use firstWhereOrNull;
example:
searchArray(String searchValue){
var test =
products.firstWhereOrNull((element) => element['name'].contains(searchValue));
print(test); //print just first object whos name property contains "MSI"
}
Or
searchArray(String searchValue) {
var test =
products.where((element) => element['name'].toString().contains(searchValue));
if (test != null) {
for (var testItem in test) {
print(testItem); //print all maps whos contains sV
}
}
}
Here is one of approach you can use to search some query through the list and add the result in another list using for in iterables
void search(String query) {
List<dynamic> searchResult = [];
for (final product in products) {
if (product["name"].toLowerCase().contains(query.toLowerCase())) {
searchResult.add(product);
print(searchResult);
return;
}
}
}
full code here
Or you can use firstWhereOrNull in dart collection as mentioned by Kendruu
Related
matlab : out of memory with convenable confi of pc
I block on my problem that I will wrote in details below. During 3 days I tried a lot of differents things, none worked.. If anyone have an idea of what to do ! Here is my message error : the call to "ft_selectdata" took 0 seconds preprocessing Out of memory. Type "help memory" for your options. Error in ft_preproc_dftfilter (line 187) tmp = exp(2*1i*pi*freqs(:)*time); % complex sin and cos Error in ft_preproc_dftfilter (line 144) filt = ft_preproc_dftfilter(filt, Fs, Fl(i), 'dftreplace', dftreplace, 'dftbandwidth', dftbandwidth(i), 'dftneighbourwidth', dftneighbourwidth(i)); % enumerate all options Error in preproc (line 464) dat = ft_preproc_dftfilter(dat, fsample, cfg.dftfreq, optarg{:}); Error in ft_preprocessing (line 375) [dataout.trial{i}, dataout.label, dataout.time{i}, cfg] = preproc(data.trial{i}, data.label, data.time{i}, cfg, begpadding, endpadding); Error in EEG_Prosocial_script (line 101) data_intpl = ft_preprocessing(cfg, allData_preprosses); 187 tmp = exp(2*1i*pi*freqs(:)*time); % complex sin and cos There is some informations from matlab about my computer and about the caracteristics of the calcul Maximum possible array: 7406 MB (7.766e+09 bytes)* Memory available for all arrays: 7406 MB (7.766e+09 bytes) * Memory used by MATLAB: 4195 MB (4.398e+09 bytes) Physical Memory (RAM): 12206 MB (1.280e+10 bytes) Limited by System Memory (physical + swap file) available. K>> whos Name Size Bytes Class Attributes freqs 7753x1 62024 double li 1x1 16 double complex time 1x1984512 15876096 double So there the config of the computer which failed to run the script (Alienware aurora R4) : Ram : 4gb free / 12 # 1,6Ghz --> 2x (4Gb 1600Mhz) - 2x (2Gb 1600 MHz) Intel core i7-3820 4 core 8 threads 3,7 GHz 1 CPU NVIDIA GeForce GTX 690 2gb RAM : Kingston KVT8FP HYC Hard disk : SSD kingston 250Go SATA 3" This code work on this computer (Dell inspiron 14-500) : config Ram 4 Go of memory DDR4 2 666 MHz (4 Go x 1) Intel® Core™ i5-8265U 8e generatio, (6 Mo memory, 3,9 GHz) Intel® UHD Graphics 620 Hard disk SATA 2,5" 500 Go 5 400 tr/min Thank you Kind regards,
by doing freqs(:)*time you are trying to create a 7753*1984512 size array, and you dont have memory for that... (you will need ~123 gigabytes for that, or 1.2309e+11 bytes, where your computer has ~7e+09) see for example the case for : f=rand(7,1); t=rand(1,19); size(f(:)*t) ans = 7 19 what you want do to is probably a for loop per time element etc.
Count no.of elements in an array and sum for every document of a collection in mongodb?
I need to count to number of all the products from all the orders and also number of products per individual order ? data in my collection ( order_fact) : {"orderid":"c3e15faf-e338-4ed5-9bbb-bbcd15295fd7","Id_cust":"10995116278711","Id_date":"91","TotalPrice":1933.53,"Orderline":[{"productId":"4165","asin":"B005G2G2SQ","title":"ESEE-6 Plain Black Blade With Grey Removable Lined Micarta Handles 1095 Carbon Steel 57-Rc","price":140.05,"brand":"Fila_(company)"},{"productId":"5916","asin":"B001CJ2LQ4","title":"Aimpoint M4s 2 Minute of Angle QRP2 CompM4 Sight with Mount","price":804.95,"brand":"Atletica"},{"productId":"7779","asin":"B003DO5L3G","title":"Lee Precision Load Master 223 Remington Reloading Rifle Kit (Red)","price":249.26,"brand":"BURRDA"},{"productId":"2722","asin":"B0017U1MJU","title":"Casio Mens PAW1500-1V Pathfinder Multi-Band Solar Atomic Ultimate Watch","price":190.27,"brand":"Reebok"},{"productId":"52","asin":"B007SYGLZO","title":"Armasight Spark CORE Multi-Purpose Night Vision Monocular","price":549.0,"brand":"Signia_(sportswear)"}],"Livreur":{"Id_livreur":"91bcee9f-8896-4e18-a24c-a8e86b97b3a1","Nom":"Tyson Anderson","gender":"Male","phone":"7-458-665-3444"}}, {"orderid":"35b26e6d-e450-4edc-9071-306cea10a083","Id_cust":"10995116278711","Id_date":"249","TotalPrice":1540.91,"Orderline":[{"productId":"1978","asin":"B001CZBMRC","title":"Benchmade Osborne Design Rift Knife","price":178.5,"brand":"CCM_(ice_hockey)"},{"productId":"857","asin":"B004IIKA2I","title":"Barnett Quad 400 Crossbow Package (Quiver 3 - 22-Inch Arrows and 4x32mm Scope)","price":354.99,"brand":"Fischer_(company)"},{"productId":"8362","asin":"B00635GTTW","title":"Schwinn IC2 Indoor Cycling Exercise Bike","price":422.49,"brand":"Admiral_Sportswear"},{"productId":"216","asin":"B000GKN45C","title":"Swagman XTC-4 Cross-Country 4-Bike Hitch Mount Rack (2-Inch Receiver Hitch)","price":349.99,"brand":"Elfin_Sports_Cars"},{"productId":"7766","asin":"B000KKEPJ2","title":"Lyman Reloading Press T-Mag Turret Press","price":234.94,"brand":"BURRDA"}],"Livreur":{"Id_livreur":"48d64c09-7a63-4fca-815a-a96921a82ee7","Nom":"Abdul Coll","gender":"Male","phone":"1-273-204-4721"}}, {"orderid":"ffaec62e-9875-42af-8789-0a97eabe77e4","Id_cust":"10995116278711","Id_date":"67","TotalPrice":1058.41,"Orderline":[{"productId":"2675","asin":"B00BPRM2O4","title":"Large Exercise Mat Large Workout Mat With A Unique Fabric Finish That Provides Excellent Traction And Floor Protection. Can Be Used In Conjunction With The Square36 YOGA Mat. The Square36 CARDIO Mat - The BIG Exercise Mat- Step Into the Square.","price":159.99,"brand":"Reebok"},{"productId":"1380","asin":"B000EQCVQ6","title":"Eureka! Apex 2XT Two-Person Tent","price":175.16,"brand":"Topper_(sports)"},{"productId":"9665","asin":"B004H4VSI8","title":"IRONMAN HIGH CAPACITY GRAVITY 3000 INVERSION TABLE","price":239.8,"brand":"Wilson_Sporting_Goods"},{"productId":"7603","asin":"B0017SC9H6","title":"Zero Tolerance Combat Folding Knife","price":199.0,"brand":"Tramontana_(sports_car)"},{"productId":"887","asin":"B00BCLL8C0","title":"SportRack SR7018 Vista XL Rear Opening Cargo Box 18-Cubic Feet","price":284.46,"brand":"Fischer_(company)"}],"Livreur":{"Id_livreur":"7548ac7b-5bf7-4c5a-a80d-5390b73b9b90","Nom":"Henry Wilde","gender":"Male","phone":"3-624-033-5243"}}, {"orderid":"125e7887-c41d-4a5a-aa6b-d2a3679d58e7","Id_cust":"10995116278711","Id_date":"477","TotalPrice":1624.98,"Orderline":[{"productId":"6250","asin":"B005DYQ9V2","title":"Invicta Men s 1463 Reserve Collection Chronograph Silver Dial Stainless Steel Watch","price":199.95,"brand":"Keuka_(brand)"},{"productId":"1138","asin":"B000AMRN12","title":"Stamina AeroPilates Reformer with Free-Form Cardio Rebounder","price":449.0,"brand":"Topper_(sports)"},{"productId":"7575","asin":"B005D7FXMA","title":"Cygolite Expilion 400 Usb Rechargeable Headlight with Quick Release Li-Ion Battery Stick and Wall Charger","price":113.99,"brand":"Derbi"},{"productId":"6529","asin":"B005Z2CYX4","title":"Zero Tolerance ZT0550 Hinderer Design Folding Knife","price":160.0,"brand":"CA_Sports"},{"productId":"7125","asin":"B007INYN6O","title":"Barnett Zombie 350 CRT Crossbow","price":702.04,"brand":"Elan_Snowboards"}],"Livreur":{"Id_livreur":"a1060a87-fdff-4acc-b728-c805b72b0740","Nom":"Percy Thornton","gender":"Male","phone":"5-744-522-0782"}}, {"orderid":"b259eafc-2f47-47dc-927b-5b6d6edbba1d","Id_cust":"10995116278711","Id_date":"617","TotalPrice":1484.76,"Orderline":[{"productId":"7667","asin":"B008W1TUAK","title":"MAGPUL ACS CARB STOCK MIL-SPEC BLACK","price":98.99,"brand":"POC_Sports"},{"productId":"6406","asin":"B001CJX50K","title":"Kinetic Rock n Roll Trainer w/Road Resistance Unit","price":389.99,"brand":"MYLAPS_Sports_Timing"},{"productId":"1883","asin":"B000O8Z7TW","title":"KNEX Education - Exploring Machines","price":126.79,"brand":"TRYMAX"},{"productId":"4158","asin":"B003AQKQAA","title":"Vortex Viper PST 6-24x50 Rifle PST-624S1-M","price":749.0,"brand":"Fila_(company)"},{"productId":"7578","asin":"B00D43A93I","title":"Under Armour Hammer 8600014-4808 Polarized Wrap Sunglasses","price":119.99,"brand":"Derbi"}],"Livreur":{"Id_livreur":"eb135eef-7ee2-4d90-b073-cbd4570935b3","Nom":"Violet Adler","gender":"Female","phone":"5-466-075-2676"}}, {"orderid":"b5755c1e-fc3f-4481-a175-edfc82290ea5","Id_cust":"10995116278711","Id_date":"208","TotalPrice":2487.71,"Orderline":[{"productId":"965","asin":"B000O3AVNY","title":"Advanced Elements AdvancedFrame Expedition Kayak","price":599.99,"brand":"Donnay_(sports)"},{"productId":"6888","asin":"B0029KL3S2","title":"Precor 240i Commercial Series StretchTrainer","price":704.2,"brand":"Elan_(company)"},{"productId":"6439","asin":"B004PJ1J4S","title":"Invicta Men s 6566 Subaqua Noma IV Collection Chronograph Black Polyurethane Watch","price":340.65,"brand":"MYLAPS_Sports_Timing"},{"productId":"9503","asin":"B0034PXYRY","title":"Eotech EXPS3-0 Holographic Weapon Site","price":606.92,"brand":"EA_Sports"},{"productId":"7740","asin":"B00271ERVI","title":"Crimson Trace Lasergrip for Ruger Lcr","price":235.95,"brand":"BURRDA"}],"Livreur":{"Id_livreur":"c75a672e-37cf-498e-8bf9-8dae7857165f","Nom":"Renee Eyres","gender":"Female","phone":"6-311-624-4031"}}, {"orderid":"8a129f4e-e736-4919-9a22-c98373f1df3b","Id_cust":"10995116278711","Id_date":"390","TotalPrice":1233.67,"Orderline":[{"productId":"1929","asin":"B004P4HH8U","title":"Barnett Ghost 350 CRT Crossbow Package (Quiver 3 - 20-Inch Arrows and Illuminated 3x32mm Scope)","price":509.99,"brand":"TRYMAX"},{"productId":"2940","asin":"B004IIZVQ8","title":"Barnett Wildcat C5 Crossbow Package (Quiver 3 - 20-Inch Arrows and Premium Red Dot Sight)","price":342.99,"brand":"Volkl"},{"productId":"3174","asin":"B006U0YZPA","title":"Bushnell X-8 6MP Trail Camera with Night Vision and Field Scan","price":136.94,"brand":"Daei_Sport"},{"productId":"6527","asin":"B003MA1SSI","title":"Sadlak Industries M14 National Match Spring Guide","price":40.75,"brand":"CA_Sports"},{"productId":"1759","asin":"B007L4ZGXE","title":"Zero Tolerance ZT0560 Hinderer Design Black Folding Knife","price":203.0,"brand":"Olympikus"}],"Livreur":{"Id_livreur":"2ccb39c1-5c1a-46d8-b394-fc887bd4cecd","Nom":"Faith Flanders","gender":"Female","phone":"2-586-775-3278"}}, {"orderid":"bb671476-5f67-414a-9b84-77498b05f0bd","Id_cust":"10995116278711","Id_date":"205","TotalPrice":1601.81,"Orderline":[{"productId":"810","asin":"B009K28INA","title":"Schwinn 425 Elliptical Trainer (2013)","price":599.99,"brand":"Fischer_(company)"},{"productId":"6802","asin":"B000WY8ZHO","title":"Luminox Men s Navy Seal ColorMark Watch 3051","price":229.09,"brand":"Onda_(sportswear)"},{"productId":"3178","asin":"B007O5B0LC","title":"Weslo Cadence G 5.9 Treadmill","price":351.0,"brand":"Daei_Sport"},{"productId":"2126","asin":"B0025YCYK8","title":"Spyderco Temperence 2 Canvas Micarta Plain Edge Knife","price":207.72,"brand":"Li-Ning"},{"productId":"6736","asin":"B002QWB8HY","title":"CamelBak BFM 3L Backpack","price":214.01,"brand":"Onda_(sportswear)"}],"Livreur":{"Id_livreur":"629b2edd-8bd4-4d50-8e63-33f4904ffd2c","Nom":"Stephanie Garcia","gender":"Female","phone":"6-618-288-6820"}}, {"orderid":"d3016947-f478-4782-941d-37132482a10a","Id_cust":"10995116278711","Id_date":"694","TotalPrice":1534.78,"Orderline":[{"productId":"3029","asin":"B00AJK9CW8","title":"Seiko Men s SRP307 Classic Automatic Dive Watch","price":192.87,"brand":"Kettler"},{"productId":"2964","asin":"B004V956P0","title":"Crosman Optimus Break Barrel Air Rifle (.177)","price":91.98,"brand":"Volkl"},{"productId":"4115","asin":"B003UNZHNY","title":"Schwinn A10 Upright Exercise Bike (2011)","price":199.99,"brand":"Fila_(company)"},{"productId":"6853","asin":"B0081MPIBA","title":"ETEK4 - Planet Eclipse Etek 4 LT / AM Paintball Guns","price":499.95,"brand":"Elan_(company)"},{"productId":"893","asin":"B001AS697O","title":"Bowflex PR1000 Home Gym","price":549.99,"brand":"Fischer_(company)"}],"Livreur":{"Id_livreur":"787192a7-8417-44a9-a5bb-dd9060afd524","Nom":"Isla Denton","gender":"Female","phone":"1-260-416-8800"}}, {"orderid":"30dd4a79-4dac-4043-8fbc-e746e78aced3","Id_cust":"10995116278711","Id_date":"702","TotalPrice":1329.04,"Orderline":[{"productId":"2726","asin":"B005SSWKMK","title":"Casio Men s PRW2500T-7CR Pathfinder Triple Sensor Tough Solar Digital Multi-Function Titanium Pathfinder Casual Watch","price":266.12,"brand":"Reebok"},{"productId":"6563","asin":"B0014NDXGA","title":"Bushnell Tour V2 Standard Edition Golf Laser Rangefinder","price":290.06,"brand":"Onda_(sportswear)"},{"productId":"4856","asin":"B001QD48GC","title":"FreeForm Hideaway Home Gym","price":641.93,"brand":"ASICS"},{"productId":"7653","asin":"B007ZNUG9K","title":"Blackhawk Black TraverseTrack Bipod - 10 - BH71BP10BK","price":50.98,"brand":"POC_Sports"},{"productId":"4166","asin":"B00AJT98OQ","title":"Universal Brass Catcher","price":79.95,"brand":"Fila_(company)"}],"Livreur":{"Id_livreur":"5acb6f8a-fb71-4b32-b40d-fde782d70600","Nom":"Belinda Marshall","gender":"Female","phone":"6-671-643-4273"}}, I need two queries, the first : Number of all the products from all the orders the second query : Number of all the products from per order
You can have something like this : For First Question : db.getCollection('order_fact').aggregate([{ $group: { _id: '', allProductsFromAllOrdersCount: { $sum: { $cond: { if: { $isArray: "$Orderline" }, then: { $size: "$Orderline" }, else: "NA"} } } } }, { $project: { _id: 0, allProductsFromAllOrdersCount: 1 } }]) For Second Question : If OrderLine is Array for sure : db.getCollection('order_fact').aggregate([{$project : {orderid:1 ,OrderLine : 1, totalNoOfProducts : { $size: "$Orderline"}}}]) else with conditional statements: db.getCollection('order_fact').aggregate([{$project : {orderid:1 ,OrderLine : 1, totalNoOfProducts : { $cond: { if: { $isArray: "$Orderline" }, then: { $size: "$Orderline" }, else: "NA"} }}}]) If you need the count along with original document to be returned : db.getCollection('order_fact').aggregate([{$addFields: {totalNoOfProducts : { $cond: { if: { $isArray: "$Orderline" }, then: { $size: "$Orderline" }, else: "NA"} }}}])
Android things lcd config
I'm trying to get a 5" LCD working with my raspberry pi 3 and Android Things Developer Preview 4.1. I've added this to my config.txt: max_usb_current=1 hdmi_group=2 hdmi_mode=1 hdmi_mode=87 hdmi_cvt 800 480 60 6 0 0 0 All I get is a white screen with some artifacts: It's not a cable issue, I can use the screen with my Windows PC just fine. I've found some maybe relevant lines in logcat: 01-01 00:00:19.529 412-412/? I/SystemServiceManager: Starting com.android.server.display.DisplayManagerService 01-01 00:00:19.568 412-434/? I/DisplayManagerService: Display device added: DisplayDeviceInfo{"Built-in Screen": uniqueId="local:0", 800 x 480, modeId 1, defaultModeId 1, supportedModes [{id=1, width=800, height=480, fps=60.000004}], colorTransformId 1, defaultColorTransformId 1, supportedColorTransforms [{id=1, colorTransform=0}], HdrCapabilities android.view.Display$HdrCapabilities#192777c, density 160, 160.0 x 160.42105 dpi, appVsyncOff 0, presDeadline 17666666, touch INTERNAL, rotation 0, type BUILT_IN, state UNKNOWN, FLAG_DEFAULT_DISPLAY, FLAG_ROTATES_WITH_CONTENT, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS} 01-01 00:00:19.571 412-434/? I/DisplayManagerService: Display device changed state: "Built-in Screen", ON 01-01 00:00:23.990 412-434/? I/WindowManager: No existing display settings /data/system/display_settings.xml; starting empty I've bought the screen from an ebay seller. It came with a dvd, and had a sample config.txt file, it suggests the same settings. What am I doing wrong?
What information is stored in EFIX/JPEG photos taken on the iPhone with geotagging enabled?
I know that some of this data is viewable in iPhoto, such as latitude, longitude, and altitude, but is there more than this available? More specifically I am wanting to get the direction of the image as well, which is part of the EXIF format. Or does something other than geotagging need to be enabled (something to do with the compass)?
I suggest installing the command line tool exif. You can get it through Mac Ports by executing port install exif as root. Here's an example of the exif info stored in a photo I took on an iPod Touch: bash:$ exif Oct\ 9\,\ 2010/IMG_0038.JPG EXIF tags in 'Oct 9, 2010/IMG_0018.JPG' ('Motorola' byte order): --------------------+---------------------------------------------------------- Tag |Value --------------------+---------------------------------------------------------- Manufacturer |Apple Model |iPod touch Orientation |right - top x-Resolution |72.00 y-Resolution |72.00 Resolution Unit |Inch Software |4.1 Date and Time |2010:10:06 17:43:43 YCbCr Positioning |centered Compression |JPEG compression x-Resolution |72.00 y-Resolution |72.00 Resolution Unit |Inch Exposure Time |1/120 sec. FNumber |f/2.4 Exposure Program |Normal program ISO Speed Ratings |320 Exif Version |Exif Version 2.21 Date and Time (origi|2010:10:06 17:43:43 Date and Time (digit|2010:10:06 17:43:43 Components Configura|Y Cb Cr - Shutter speed |6.91 EV (1/120 sec.) Aperture |2.53 EV (f/2.4) Metering Mode |Average Flash |No flash function Focal Length |3.9 mm FlashPixVersion |FlashPix Version 1.0 Color Space |sRGB PixelXDimension |640 PixelYDimension |480 Sensing Method |One-chip color area sensor Exposure Mode |Auto exposure White Balance |Auto white balance Scene Capture Type |Standard Sharpness |Normal North or South Latit|N Latitude |44.00, 22.12, 0.00 East or West Longitu|W Longitude |56.00, 23.98, 0.00 GPS time (atomic clo|17:43:41.60 --------------------+---------------------------------------------------------- EXIF data contains a thumbnail (10215 bytes). I don't think the iPod Touch has the same capabilities as an iPhone regarding GPS. It looks like an iPhone will have the data 'GPSImg Direction' as well, which sounds like what you want. I don't think you have to do anything special to enable it, as I haven't found much info on this through searching.
Okay, good news :). The direction is stored in GPS Img Direction. Here's what I was able to get from a photo taken from an iphone (with location services and compass turned on) using the ExifTool mentioned by #rwong. ExifTool Version Number : 8.34 File Name : photo.JPG Directory : C:/Documents and Settings/user/My Document s/Downloads File Size : 349 kB File Modification Date/Time : 2010:10:19 14:05:39-06:00 File Permissions : rw-rw-rw- File Type : JPEG MIME Type : image/jpeg JFIF Version : 1.01 Exif Byte Order : Big-endian (Motorola, MM) Image Description : Back Camera Make : Apple Camera Model Name : iPhone Orientation : Horizontal (normal) X Resolution : 72 Y Resolution : 72 Resolution Unit : inches Software : 4.0.1 Modify Date : 2010:10:19 14:00:52 Y Cb Cr Positioning : Centered Exposure Time : 1/146 F Number : 2.4 Exposure Program : Program AE ISO : 80 Exif Version : 0221 Date/Time Original : 2010:10:19 14:00:52 Create Date : 2010:10:19 14:00:52 Shutter Speed Value : 1/146 Aperture Value : 2.4 Metering Mode : Average Flash : Off, Did not fire Focal Length : 3.9 mm Subject Area : 1295 967 699 696 Flashpix Version : 0100 Color Space : sRGB Exif Image Width : 1296 Exif Image Height : 968 Sensing Method : One-chip color area Exposure Mode : Auto White Balance : Auto Scene Capture Type : Standard Sharpness : Hard GPS Latitude Ref : North GPS Longitude Ref : West GPS Time Stamp : 14:00:46.81 GPS Img Direction Ref : True North GPS Img Direction : 32.52336904 Image Width : 1296 Image Height : 968 Encoding Process : Baseline DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2) Aperture : 2.4 GPS Latitude : 45 deg 14' 58.20" N GPS Longitude : 121 deg 39' 4.80" W GPS Position : 45 deg 14' 58.20" N, 121 deg 39' 4.80" W Image Size : 1296x968 Shutter Speed : 1/146 Focal Length : 3.9 mm Light Value : 10.0
you don't need an 'external' tool to view all the EXIF-infos, with the iPhone-app iMetaPhoto you can show all metainfos (EXIF, TIFF, IPTC, GPS, AUXiliary EXIF,...) and (the best of all) you can modify the most of them, esp. you can modify GPS ImgDirection.
How to read a file in and replace the value with a name
I have a file of with what I will call source IDs. I want to read that file and based on the source ID add a name to it, for example 15431 = MyTV8. I have a file that lists the source ID and the name, but I'm not sure how to read the original IDs in and add the names from the channel map file to the file with the source IDs. A small sample of the source IDs I poll 13431 0 4112 4129 11412 0 0 12055 0 0 4129 0 0 12125 12120 0 10959 5370 5380 4109 0 20121 0 12334 11493 0 0 4107 5687 0 4008 0 0 4166 5378 4203 0 12056 0 0 0 0 4286 4183 0 0 4129 4037 0 10555 12209 11205 8846 0 0 5380 4719 0 4166 4117 4150 0 4183 0 4123 10391 0 4183 4151 5531 4107 4179 4185 4203 4203 0 4107 They are just in a text file and here is the source-ID channel map 1052 SCIFI 1053 COMEDY 1066 CSPAN2 1067 ESPN CLASSIC 1100 SUNSHINE FOOTBALL 1133 TRUTV 1241 SHOWTIME 2 EAST 1312 MC METAL 1315 MC KIDS ONLY 1318 MC HIP HOP & R&B 1319 MC MC MIX TAPE 1324 MC LITE CLASSICAL 1326 MC SINGERS & SWING 1330 MC R&B CLASSICS 1332 MC MEXICANA 1334 MC RAGGAE 1338 MC HIP HOP CLASSICS 1339 MC SOUND OF SEASON 1340 MC HIT LIST 1346 MC PARTY FAVORITES 1348 MC POP HITS 2006 COLLEGE SPORTS TV 2469 WGCU WORLD 2470 WGCU ED TV 3014 ACTION MAX WEST 3048 SHOWTIME SHOWCASE 3 3051 STARZ! 1 WEST 3059 JEWELRY TV 3064 STARZ! IN BLACK 3068 WAM. 3069 STARZ! 5 CINEMA WEST 3093 NICK TOO 4003 ACTION WEST 4008 NOGGIN 4011 ENCORE DRAMA EAST 4029 LOGO MTV 4037 MOVIEPLEX 4068 FCS SOCC 4070 EWTN DIGITAL 4081 TELEFUTURA 4100 ADS-AMC 4101 ADS-A&E 4103 ADS-BET 4104 ADS-BRVO 4105 ADS-C-SPAN 4107 ADS-TOON 4108 ADS-CMT 4109 ADS-CNBC 4110 ADS-CNN 4112 ADS-CMDY 4115 ADS-TRUTV/COURT-TV 4117 ADS-E! 4119 ADS-ESPN 4120 ADS-ESPN2 4121 ADS-EWTN 4123 ADS-HALLMARK 4124 FIT TV 4125 ADS-FX 4127 ADS-CCTV 4128 ADS-HIST 4129 ADS-HGTV 4130 ADS-HSN 4150 ADS-MSNBC 4151 ADS-MTV 4156 ADS-NICK 4157 BARKER 4159 PLAYBOY DIR. CUT /CP 4163 ADS-STYLE 4164 ADS-QVC 4166 ADS-SCIFI 4178 ADS-DSC 4179 ADS-FAM 4181 ADS-TLC 4182 ADS-SPIKE 4183 ADS-USA 4184 ADS-TWC-DIGITAL 4185 ADS-TNT 4186 ADS-FOOD 4187 ADS-VH-1 4203 ADS-FXNEW 4241 ADS-TRAVL 4286 ADS-TCM 4460 GAME SHOW 4485 MTV2. 4545 SUNDANCE EAST 4557 ADS-TVL 4702 ADS-VERSUS 4705 ADS-SPEED 4719 ADS-GOLF 4730 ADS-WGN 5012 ADS TEST 1 5013 ADS TEST 2 5014 ADS TEST 3 5015 ADS TEST 4 5016 ADS TEST 5 5017 ADS TEST 6 5018 ADS TEST 7 5019 ADS TEST 8 5020 ADS TEST 9 5021 ADS TEST 10 5022 ADS TEST 11 5023 ADS TEST 12 5024 SUN SPORTS HD 5286 SHOP NBC. 5368 ADS-WEDU 5369 ADS-WXPX 5370 ADS-WFLA 5377 ADS-WTOG 5378 ADS-WTSP 6031 ADS-WRXY 6166 ADS-WWSB 6206 ADS-WZVN 6884 DXD / TOON DISNEY 7064 MY38 WB HD 7077 BLOOMBERG TV 7085 BIG TEN 7086 BIG TEN 2 7090 ADS-HALLMARK VS 7331 CURRENT TV 7795 G4. 8282 BIOGRAPHY 8285 HISTORY INTER. 8434 ADS-WTTA 8445 OUTDOOR CH 8499 OXYGEN 8675 DO IT YOURSELF 8841 WEATHERSCAN 8846 LIFETIME MOVIE NET. 8888 BRAVO 9144 NHL & MLB GAME 1 9145 NHL & MLB GAME 2 9145 NHL & MLB GAME 2 9145 NHL & MLB GAME 2 9146 NHL & MLB GAME 3 9146 NHL & MLB GAME 3 9147 NHL & MLB GAME 4 9147 NHL & MLB GAME 4 9147 NHL & MLB GAME 4 9148 NHL & MLB GAME 5 9148 NHL & MLB GAME 5 9148 NHL & MLB GAME 5 9149 NHL & MLB GAME 6 9149 NHL & MLB GAME 6 9149 NHL & MLB GAME 6 9150 NHL & MLB GAME 7 9150 NHL & MLB GAME 7 9150 NHL & MLB GAME 7 9151 NHL & MLB GAME 8 9151 NHL & MLB GAME 8 9151 NHL & MLB GAME 8 9152 NHL & MLB GAME 9 9152 NHL & MLB GAME 9 9152 NHL & MLB GAME 9 9153 NHL & MLB GAME 10 9153 NHL & MLB GAME 10 9201 FUSE 9237 THEN / GAS 9472 C-SPAN3 9544 TV GAMES 9550 SOAPNET 9597 GAC 10000 CINEMAX 10001 ENCORE EAST 10002 HBO-2 10004 HBO-3 SIGNATURE 10005 SHOWTIME EAST 10006 STARZ! 1 EAST 10008 DISNEY CHANNEL. 10010 TMC 10011 SHOWTIME EXTREME E 10012 HBO WEST 10014 CINEMAX WEST 10021 ADS-ANPL 10023 CINEMAX MORE MAX -2 10025 TMC XTRA 2 EAST 10026 ACTION MAX EAST 10028 THRILLER MAX EAST 10041 NICKTOONS 10042 MTV JAMS 10045 VH-1 SOUL 10046 CMT PURE 10057 OUTERMAX EAST 10063 STARZ! 4 KIDS FAMILY 10065 STARZ! 5 CINEMA EAST 10067 VH-1 CLASSIC 10098 HBO LATINO E 10389 WORD 10391 NATIONAL GEOGRAPHIC 10398 DAYSTAR TV 10475 SHOWTIME FAMILY 10555 #MAX EAST 10556 WOMANMAX 10558 5STARMAX EAST 10584 FCS ATL 10585 FCS CEN 10586 FCS PAC 10911 SHOWTIME HDTV 10935 THEATER HD CMCHD4 10959 MTV HITS 10962 FINE LIVING/COOK TV 11101 ADS-CW6/WTVK46 11126 ADS-PAX / ION 11132 ADS-WMOR 11205 ADS-SNN 11242 RFD-TV 11299 ADS-ESPN HD 11320 ADS-LIFE 11324 ADS-FSN-FLORIDA 11328 ADS-CC-SPORT-S 11406 ADS-DHC 11411 ADS-SUN 11412 ADS-CNN-HDLN 11414 ESPNU 11431 NBA TV 11446 SPORTSMAN 11493 TENNIS TV 11514 ESPN SPPV1 11515 ESPN SPPV2 11516 ESPN SPPV3 11517 ESPN SPPV4 11518 ESPN SPPV5 11519 ESPN SPPV6 11647 GOL TV 11684 UNIVERSAL HD CMCHD2 11714 STARZ COMEDY 11716 STARZ HD 11855 TV ONE. 11911 ADS-TNTHD 12002 CENTRIC 12016 HBO EAST 12020 IFC 12023 LOVE STORIES E. 12027 MYSTERY EAST 12030 OVATION 12032 SHOWTIME 2 EAST 12037 STARZ! EDGE 12044 WESTERNS EAST 12045 ACTION EAST 12049 DISCOVERY KIDS 12050 PLANET GREEN 12051 DISCOVERY SCIENCE 12055 WE. 12056 MILITARY CHANNEL. 12112 ESPNEWS 12120 DISC ID 12125 NFL NETWORK 12130 FLIX EAST 12174 SHOWTIME BEYOND EAST 12175 BBC AMERICA 12209 ADS-TBS 12306 ADS-REALTY-TV-PC 12333 ADS-LOPC 12334 ADS-ACCESS-CH-19 12336 ADS-SARASOTA-ED 12339 ADS-LO 12340 ADS-TV-GUIDE 12393 WXPXHD 12800 ADS-ESPN2HD 12810 WFTX FOX HD 12817 ADS-TBS HD 13008 HBO ZONE EAST 13011 HBO FAMILY EAST 13013 HBO COMEDY EAST 13017 WZVN PC HDTV 13039 WBBH PC HDTV 13050 NAT GEO WILD 13072 HALLMARK MOVIE CH 13104 GOSPEL MUSIC TV 13135 HBO HD CMCHD5 13136 MAX HD CMCHD5 13229 SPROUT "E" NETWORKS 13268 WFLA NBC HD 13289 WTVT FOX HD 13406 EMPLOYEE CHANNEL 13430 INDIEPLEX 13431 RETROPLEX 13467 ADS-SCI-FI HD 13551 PALADIEA HD 13738 HGTV HD CMCHD1 13745 NATGEO HD CMCHD3 13907 TV FOOD HD CMCHD2 14102 NFLHD 14507 ADS-WNFM-8 14710 A&E HD CMCHD1 15000 IN DEMAND 1 15001 IN DEMAND 2 15045 SHORTEEZ ADULT 15067 NBA TEAM 1 15068 NBA TEAM 2 15069 NBA TEAM 3 15070 NBA TEAM 4 15071 NBA TEAM 5 15072 NBA TEAM 6 15073 NBA TEAM 7 15074 NBA TEAM 8 15075 NBA TEAM 9 15076 NBA TEAM 10 15128 REELZ 15201 VERSUS - HD 15238 NHL & MLB GAME 14 15239 NHL & MLB GAME 13 15240 NHL & MLB GAME 12 15241 NHL & MLB GAME 11 15364 MTV SPANISH TR3 15542 PENTHOUSE/TEN ADULT 16116 ADS-FOX BUSINESS 16120 ANIMAL HD CMCHD4 16121 SCIENCE HD CMCHD8 16122 TDC HD CMCHD3 16123 TLC HD CMCHD5 16129 USA HD CMCHD3 16141 CNN HD CMCHD7 16240 LIFETIME MOVIENET HD 16280 NHL NETWORK 16317 RETIREMENT TV 16346 FX HD CMCHD9 16403 GOLF HD CMCHD7 16414 AMC HD CMCHD7 16430 BIOGRAPHY HD 16543 SPEED HD CMCHD9 16547 SPIKE HD 16686 DISNEY HD CMCHD-8 16692 FAMILY HD CMCHD8 16713 NICKELODEON HD 16756 FOX NEWS HD CMCHD9 16788 WEDU HD 16792 WTSP DIGITAL WEATHER 16793 WTSP HDTV 16798 LIFETIME HD 16807 WWSB HDTV 16817 PLANET GREEN HD 17000 FRESH ADULT 17512 MLB NETWORK 17535 MLBHD 18030 WGCU HD PBS 18324 HEADLINE NEWS HD 18333 TCM HD 18411 TRU TV HD 18630 FOX SPORTSNET FL HD 19005 3DTV 1 19421 3DTV 2 20101 MC 90'S 20102 MC ADULT ALTERNATIVE 20104 MC RAP 20105 MC THROWBACK JAMZ 20106 MC CONTEMP CHRISTIAN 20107 MC CLASSIC COUNTRY 20108 MC TODAY'S COUNTRY 20110 MC ROCK 20112 MC GOSPEL 20113 MC RETRO ROCK 20115 MC TODDLER TUNES 20116 MC SOFT ROCK 20119 MC SOUNDSCAPES 20120 MC JAZZ 20121 MC SMOOTH JAZZ 20122 MC CLASSICAL MASTERP 20124 MC 80'S 20126 MC EASY LISTENING 20127 MC POP LATINO 20128 MC SOLID GOLD OLDIES 20129 MC R&B SOUL 20131 MC TRUE COUNTRY 20282 MC STAGE & SCREEN 20284 MC MUSICA URBANA 20287 MC TROPICALS 20289 MC CLASSIC ROCK 20338 MC CLASSIC ALTERNATV 20339 MC DANCE ELECTRONICA 20357 MC ALTERNATIVE 20358 MC ROMANCES 20359 MC BLUES 20360 MC 70'S 21170 STARZ! HD CMCHD1 21203 SCI FI HD CMCHD2 21442 THC HD CMCHD4 23104 E! HD 23105 TRAVEL HD 23106 CARTOON HD 23107 CSS HD. 23109 NFL RED ZONE 23110 IND HDPPV 23111 IND HDPPV2 23112 ESPNU HD
There is a general pattern here, and it is this: this is a set intersection problem, and as such can be solved easily with Perl "sets", which we tend to call hashes :). The approach is to create a set out of one of your data files (ie. indexing it into a hash table, like so: %set = (a => 1, b => 1, c => 1), where the actual value is immaterial, since we're going to be testing it with the "set membership operator" exists). Once you have that, it is a simple matter of going through the other data set, and test membership of one of its keys (in your case, source IDs) in the %set above. So, assuming the channel map file is in the following format: ID,NAME and the source ID file is just one ID per line, the you could do the following: open my $CHANNEL_MAP, q{<}, $channel_map_file_name or die $!; my %channel_map = map { chomp; my #mapping = split /,/; $mapping[0] => $mapping[1] # not needed, just being explicit. } <$CHANNEL_MAP>; close $CHANNEL_MAP or die $!; # source ID file passed as a command line argument while (<>) { chomp; print "$_ = $channel_map{$_}\n" if exists $channel_map{$_}; } However, this seems a bit pointless, since all you seem to want to do is to filter the channel map file by the existing source IDs. In that case, you could simply index the source ID file instead (use the technique above), and then simply go through the channel mappings file and print each line for which the ID exists in your source IDs.
It's all rather fuzzy since you're not clear on the formats of your files. But, assuming you have a file called names.txt that lists the name in the "15431 = MyTV8" format, one per line, and you have the other file while lists only numbers, you could use something like this: #!/usr/bin/perl open NAMES, '< names.txt' or die $#; my %names = map { /(\d+) = (.+)/; ($1, $2) } (<NAMES>); while (<>) { chomp; if (exists $names{$_}) { print "$_ = $names{$_}\n"; } else { print "$_\n"; } }