Question: I'm trying to retrieve values from multiple csv files that are located in a directory. When performing `if row['opponent-points-per-game-rank'] == 6:` I am getting a Key Error. When I do something like:

```
if 'opponent-points-per-game-rank' in myfilereader.fieldnames:
    testrank = [row.get('opponent-points-per-game-rank') for row in myfilereader]

```

It will find the column name. Any reason why it can find the column name this way but not the other? Here is the [link](https://drive.google.com/file/d/1D4aEqJogIt_typdgRHLNJhfWI-Os8iLI/view?usp=sharing) to my csv file. My code right now:

```
import os
import csv

testrank = []

directory = os.path.join("c:\\","Users\sm\OneDrive\TestProject") 

for root,dirs,files in os.walk(directory):
    for file in files:
       if file.endswith(".csv"):
           f=open(file, 'r')
           myfilereader = csv.DictReader(f)
           for row in myfilereader:
               if row['opponent-points-per-game-rank'] == 6:
                  testrank.append(row['Team'])
           f.close() 

print(testrank)

```

Answer: 
to save the object:

> 
> 1. convert your object to map with `toMap()` method
> 2. serialize your map to string with `serialize(...)` method
> 3. save the string into secure storage
> 
> 
> 

for restoring your object:

> 
> 1. deserialize secure storage string to a map with `deserialize(...)` method
> 2. use `fromJson()` method to get your object
> 
> 
> 

by that, you will serialize your data into a string and save and retrieve them.

```dart
class MyUserModel {
    String authKey;
    String city;
    String contact;
    dynamic email;
    bool isContact;
    int userId;

  MyUserModel({
    required this.authKey,
    required this.city,
    required this.contact,
    required this.email,
    required this.isContact,
    required this.userId,
  });

  factory MyUserModel.fromJson(Map<String, dynamic> jsonData) =>
    MyUserModel(
      authKey: jsonData['auth_key'],
      city: jsonData['city'],
      contact: jsonData['contact'],
      email: jsonData['email'],
      isContact: jsonData['is_contact'] == '1',
      userId: jsonData['user_id'],
    );
  }

  static Map<String, dynamic> toMap(MyUserModel model) => 
    <String, dynamic> {
      'auth_key': model.authKey,
      'city': model.city,
      'contact': model.contact,
      'email': model.email,
      'is_contact': model.isContact ? '1' : '0',
      'user_id': model.userId,
    };

  static String serialize(MyUserModel model) =>
    json.encode(MyUserModel.toMap(model));

  static MyUserModel deserialize(String json) =>
    MyUserModel.fromJson(jsonDecode(json));
}

```

Usage:

```dart
final FlutterSecureStorage storage = FlutterSecureStorage();

await storage.write(key: key, value: MyUserModel.serialize(model));

MyUserModel model = MyUserModel.deserialize(await storage.read(key: key));

```
You can do this by encoding your Model into json saving it in `Secure Storage` and then decode the json and get the model back.

```
// Saving model into Storage
static Future<void> setMyUserModel(MyUserModel user) async {
  await const FlutterSecureStorage().write(
    key: 'user', value: user.toRawJson());
}

// Getting model from storage
static Future<MyUserModel> getMyUserModel() async {
  return MyUserModel.fromRawJson(
      await const FlutterSecureStorage().read(key: 'user') ??
          '{}');
}

```

And of course you need to implement `fromRawJson()` and `toRawJson()` inside your model.

Sorry for the late reply :P.